summaryrefslogtreecommitdiff
path: root/vendor/github.com/onsi/ginkgo/internal/codelocation/code_location_test.go
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2019-02-05 11:51:41 +0100
committerValentin Rothberg <rothberg@redhat.com>2019-02-06 11:14:06 +0100
commit9ac0ebb0791851aea81ecc847802db5a39bfb6e7 (patch)
tree30ad98bcc2c2dd1136f46a48cbc44d422adfa184 /vendor/github.com/onsi/ginkgo/internal/codelocation/code_location_test.go
parent51714d5da7aaa19014fd67b48b79dfbd5f69c1f0 (diff)
downloadpodman-9ac0ebb0791851aea81ecc847802db5a39bfb6e7.tar.gz
podman-9ac0ebb0791851aea81ecc847802db5a39bfb6e7.tar.bz2
podman-9ac0ebb0791851aea81ecc847802db5a39bfb6e7.zip
Cirrus: add vendor_check_task
* Make sure that all vendored dependencies are in sync with the code and the vendor.conf by running `make vendor` with a follow-up status check of the git tree. * Vendor ginkgo and gomega to include the test dependencies. Signed-off-by: Chris Evic <cevich@redhat.com> Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'vendor/github.com/onsi/ginkgo/internal/codelocation/code_location_test.go')
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/codelocation/code_location_test.go80
1 files changed, 80 insertions, 0 deletions
diff --git a/vendor/github.com/onsi/ginkgo/internal/codelocation/code_location_test.go b/vendor/github.com/onsi/ginkgo/internal/codelocation/code_location_test.go
new file mode 100644
index 000000000..cca75a449
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/codelocation/code_location_test.go
@@ -0,0 +1,80 @@
+package codelocation_test
+
+import (
+ "runtime"
+
+ . "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/internal/codelocation"
+ "github.com/onsi/ginkgo/types"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("CodeLocation", func() {
+ var (
+ codeLocation types.CodeLocation
+ expectedFileName string
+ expectedLineNumber int
+ )
+
+ caller0 := func() {
+ codeLocation = codelocation.New(1)
+ }
+
+ caller1 := func() {
+ _, expectedFileName, expectedLineNumber, _ = runtime.Caller(0)
+ expectedLineNumber += 2
+ caller0()
+ }
+
+ BeforeEach(func() {
+ caller1()
+ })
+
+ It("should use the passed in skip parameter to pick out the correct file & line number", func() {
+ Ω(codeLocation.FileName).Should(Equal(expectedFileName))
+ Ω(codeLocation.LineNumber).Should(Equal(expectedLineNumber))
+ })
+
+ Describe("stringer behavior", func() {
+ It("should stringify nicely", func() {
+ Ω(codeLocation.String()).Should(ContainSubstring("code_location_test.go:%d", expectedLineNumber))
+ })
+ })
+
+ //There's no better way than to test this private method as it
+ //goes out of its way to prune out ginkgo related code in the stack trace
+ Describe("PruneStack", func() {
+ It("should remove any references to ginkgo and pkg/testing and pkg/runtime", func() {
+ input := `/Skip/me
+Skip: skip()
+/Skip/me
+Skip: skip()
+/Users/whoever/gospace/src/github.com/onsi/ginkgo/whatever.go:10 (0x12314)
+Something: Func()
+/Users/whoever/gospace/src/github.com/onsi/ginkgo/whatever_else.go:10 (0x12314)
+SomethingInternalToGinkgo: Func()
+/usr/goroot/pkg/strings/oops.go:10 (0x12341)
+Oops: BlowUp()
+/Users/whoever/gospace/src/mycode/code.go:10 (0x12341)
+MyCode: Func()
+/Users/whoever/gospace/src/mycode/code_test.go:10 (0x12341)
+MyCodeTest: Func()
+/Users/whoever/gospace/src/mycode/code_suite_test.go:12 (0x37f08)
+TestFoo: RunSpecs(t, "Foo Suite")
+/usr/goroot/pkg/testing/testing.go:12 (0x37f08)
+TestingT: Blah()
+/usr/goroot/pkg/runtime/runtime.go:12 (0x37f08)
+Something: Func()
+`
+ prunedStack := codelocation.PruneStack(input, 1)
+ Ω(prunedStack).Should(Equal(`/usr/goroot/pkg/strings/oops.go:10 (0x12341)
+Oops: BlowUp()
+/Users/whoever/gospace/src/mycode/code.go:10 (0x12341)
+MyCode: Func()
+/Users/whoever/gospace/src/mycode/code_test.go:10 (0x12341)
+MyCodeTest: Func()
+/Users/whoever/gospace/src/mycode/code_suite_test.go:12 (0x37f08)
+TestFoo: RunSpecs(t, "Foo Suite")`))
+ })
+ })
+})