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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
|
package testingtproxy_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
"github.com/onsi/ginkgo/internal/testingtproxy"
)
type messagedCall struct {
message string
callerSkip []int
}
var _ = Describe("Testingtproxy", func() {
var t GinkgoTInterface
var failFunc func(message string, callerSkip ...int)
var skipFunc func(message string, callerSkip ...int)
var failedFunc func() bool
var nameFunc func() string
var nameToReturn string
var failedToReturn bool
var failFuncCall messagedCall
var skipFuncCall messagedCall
var offset int
var buf *gbytes.Buffer
BeforeEach(func() {
failFuncCall = messagedCall{}
skipFuncCall = messagedCall{}
nameToReturn = ""
failedToReturn = false
offset = 3
failFunc = func(message string, callerSkip ...int) {
failFuncCall.message = message
failFuncCall.callerSkip = callerSkip
}
skipFunc = func(message string, callerSkip ...int) {
skipFuncCall.message = message
skipFuncCall.callerSkip = callerSkip
}
failedFunc = func() bool {
return failedToReturn
}
nameFunc = func() string {
return nameToReturn
}
buf = gbytes.NewBuffer()
t = testingtproxy.New(buf, failFunc, skipFunc, failedFunc, nameFunc, offset)
})
It("ignores Cleanup", func() {
GinkgoT().Cleanup(func() {
panic("bam!")
}) //is a no-op
})
It("supports Error", func() {
t.Error("a", 17)
Ω(failFuncCall.message).Should(Equal("a 17\n"))
Ω(failFuncCall.callerSkip).Should(Equal([]int{offset}))
})
It("supports Errorf", func() {
t.Errorf("%s %d!", "a", 17)
Ω(failFuncCall.message).Should(Equal("a 17!"))
Ω(failFuncCall.callerSkip).Should(Equal([]int{offset}))
})
It("supports Fail", func() {
t.Fail()
Ω(failFuncCall.message).Should(Equal("failed"))
Ω(failFuncCall.callerSkip).Should(Equal([]int{offset}))
})
It("supports FailNow", func() {
t.Fail()
Ω(failFuncCall.message).Should(Equal("failed"))
Ω(failFuncCall.callerSkip).Should(Equal([]int{offset}))
})
It("supports Fatal", func() {
t.Fatal("a", 17)
Ω(failFuncCall.message).Should(Equal("a 17\n"))
Ω(failFuncCall.callerSkip).Should(Equal([]int{offset}))
})
It("supports Fatalf", func() {
t.Fatalf("%s %d!", "a", 17)
Ω(failFuncCall.message).Should(Equal("a 17!"))
Ω(failFuncCall.callerSkip).Should(Equal([]int{offset}))
})
It("ignores Helper", func() {
GinkgoT().Helper() //is a no-op
})
It("supports Log", func() {
t.Log("a", 17)
Ω(string(buf.Contents())).Should(Equal("a 17\n"))
})
It("supports Logf", func() {
t.Logf("%s %d!", "a", 17)
Ω(string(buf.Contents())).Should(Equal("a 17!\n"))
})
It("supports Name", func() {
nameToReturn = "C.S. Lewis"
Ω(t.Name()).Should(Equal("C.S. Lewis"))
Ω(GinkgoT().Name()).Should(ContainSubstring("supports Name"))
})
It("ignores Parallel", func() {
GinkgoT().Parallel() //is a no-op
})
It("supports Skip", func() {
t.Skip("a", 17)
Ω(skipFuncCall.message).Should(Equal("a 17\n"))
Ω(skipFuncCall.callerSkip).Should(Equal([]int{offset}))
})
It("supports SkipNow", func() {
t.SkipNow()
Ω(skipFuncCall.message).Should(Equal("skip"))
Ω(skipFuncCall.callerSkip).Should(Equal([]int{offset}))
})
It("supports Skipf", func() {
t.Skipf("%s %d!", "a", 17)
Ω(skipFuncCall.message).Should(Equal("a 17!"))
Ω(skipFuncCall.callerSkip).Should(Equal([]int{offset}))
})
It("always returns false for Skipped", func() {
Ω(GinkgoT().Skipped()).Should(BeFalse())
})
It("returns empty string for TempDir", func() {
Ω(GinkgoT().TempDir()).Should(Equal(""))
})
})
|