File: report_entry.go

package info (click to toggle)
golang-github-onsi-ginkgo-v2 2.15.0-1~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 4,112 kB
  • sloc: javascript: 59; sh: 14; makefile: 7
file content (39 lines) | stat: -rw-r--r-- 850 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package internal

import (
	"time"

	"github.com/onsi/ginkgo/v2/types"
)

type ReportEntry = types.ReportEntry

func NewReportEntry(name string, cl types.CodeLocation, args ...interface{}) (ReportEntry, error) {
	out := ReportEntry{
		Visibility: types.ReportEntryVisibilityAlways,
		Name:       name,
		Location:   cl,
		Time:       time.Now(),
	}
	var didSetValue = false
	for _, arg := range args {
		switch x := arg.(type) {
		case types.ReportEntryVisibility:
			out.Visibility = x
		case types.CodeLocation:
			out.Location = x
		case Offset:
			out.Location = types.NewCodeLocation(2 + int(x))
		case time.Time:
			out.Time = x
		default:
			if didSetValue {
				return ReportEntry{}, types.GinkgoErrors.TooManyReportEntryValues(out.Location, arg)
			}
			out.Value = types.WrapEntryValue(arg)
			didSetValue = true
		}
	}

	return out, nil
}