...

Source file src/github.com/onsi/ginkgo/v2/internal/report_entry.go

Documentation: github.com/onsi/ginkgo/v2/internal

     1  package internal
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/onsi/ginkgo/v2/types"
     7  )
     8  
     9  type ReportEntry = types.ReportEntry
    10  
    11  func NewReportEntry(name string, cl types.CodeLocation, args ...interface{}) (ReportEntry, error) {
    12  	out := ReportEntry{
    13  		Visibility: types.ReportEntryVisibilityAlways,
    14  		Name:       name,
    15  		Location:   cl,
    16  		Time:       time.Now(),
    17  	}
    18  	var didSetValue = false
    19  	for _, arg := range args {
    20  		switch x := arg.(type) {
    21  		case types.ReportEntryVisibility:
    22  			out.Visibility = x
    23  		case types.CodeLocation:
    24  			out.Location = x
    25  		case Offset:
    26  			out.Location = types.NewCodeLocation(2 + int(x))
    27  		case time.Time:
    28  			out.Time = x
    29  		default:
    30  			if didSetValue {
    31  				return ReportEntry{}, types.GinkgoErrors.TooManyReportEntryValues(out.Location, arg)
    32  			}
    33  			out.Value = types.WrapEntryValue(arg)
    34  			didSetValue = true
    35  		}
    36  	}
    37  
    38  	return out, nil
    39  }
    40  

View as plain text