Skip to content

Commit 0a618d4

Browse files
committed
update GinkgoT to support new Output and Attr testing.T functions
1 parent 86fda3a commit 0a618d4

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

ginkgo_t_dsl.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package ginkgo
22

33
import (
44
"context"
5+
"io"
56
"testing"
67

78
"github.com/onsi/ginkgo/v2/internal/testingtproxy"
@@ -69,6 +70,8 @@ type GinkgoTInterface interface {
6970
Skipf(format string, args ...any)
7071
Skipped() bool
7172
TempDir() string
73+
Attr(key, value string)
74+
Output() io.Writer
7275
}
7376

7477
/*

internal/testingtproxy/testing_t_proxy.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,3 +229,9 @@ func (t *ginkgoTestingTProxy) ParallelTotal() int {
229229
func (t *ginkgoTestingTProxy) AttachProgressReporter(f func() string) func() {
230230
return t.attachProgressReporter(f)
231231
}
232+
func (t *ginkgoTestingTProxy) Output() io.Writer {
233+
return t.writer
234+
}
235+
func (t *ginkgoTestingTProxy) Attr(key, value string) {
236+
t.addReportEntry(key, value, internal.Offset(1), types.ReportEntryVisibilityFailureOrVerbose)
237+
}

internal/testingtproxy/testingtproxy_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,4 +440,24 @@ var _ = Describe("Testingtproxy", func() {
440440
Ω(attachProgressReporterCancelCalled).Should(BeTrue())
441441
})
442442

443+
Describe("Output", func() {
444+
It("returns the GinkgoWriter", func() {
445+
fmt.Fprintln(t.Output(), "hi 3")
446+
Ω(string(buf.Contents())).Should(Equal(" hi 3\n"))
447+
})
448+
})
449+
450+
Describe("Attr", func() {
451+
It("adds report entries with visibility FailureOrVerbose", func() {
452+
cl := types.NewCodeLocation(0)
453+
t.Attr("hey", "3")
454+
entry := CurrentSpecReport().ReportEntries[0]
455+
Ω(entry.Visibility).Should(Equal(types.ReportEntryVisibilityFailureOrVerbose))
456+
Ω(entry.Name).Should(Equal("hey"))
457+
Ω(entry.GetRawValue()).Should(Equal("3"))
458+
Ω(entry.Location.FileName).Should(Equal(cl.FileName))
459+
Ω(entry.Location.LineNumber).Should(Equal(cl.LineNumber + 1))
460+
})
461+
})
462+
443463
})

0 commit comments

Comments
 (0)