/usr/share/gocode/src/github.com/smartystreets/goconvey/convey/story_conventions_test.go is in golang-github-smartystreets-goconvey-dev 1.6.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | package convey
import (
"reflect"
"testing"
)
func expectPanic(t *testing.T, f string) interface{} {
r := recover()
if r != nil {
if cp, ok := r.(*conveyErr); ok {
if cp.fmt != f {
t.Error("Incorrect panic message.")
}
} else {
t.Errorf("Incorrect panic type. %s", reflect.TypeOf(r))
}
} else {
t.Error("Expected panic but none occured")
}
return r
}
func TestMissingTopLevelGoTestReferenceCausesPanic(t *testing.T) {
output := map[string]bool{}
defer expectEqual(t, false, output["good"])
defer expectPanic(t, missingGoTest)
Convey("Hi", func() {
output["bad"] = true // this shouldn't happen
})
}
func TestMissingTopLevelGoTestReferenceAfterGoodExample(t *testing.T) {
output := map[string]bool{}
defer func() {
expectEqual(t, true, output["good"])
expectEqual(t, false, output["bad"])
}()
defer expectPanic(t, missingGoTest)
Convey("Good example", t, func() {
output["good"] = true
})
Convey("Bad example", func() {
output["bad"] = true // shouldn't happen
})
}
func TestExtraReferencePanics(t *testing.T) {
output := map[string]bool{}
defer expectEqual(t, false, output["bad"])
defer expectPanic(t, extraGoTest)
Convey("Good example", t, func() {
Convey("Bad example - passing in *testing.T a second time!", t, func() {
output["bad"] = true // shouldn't happen
})
})
}
func TestParseRegistrationMissingRequiredElements(t *testing.T) {
defer expectPanic(t, parseError)
Convey()
}
func TestParseRegistration_MissingNameString(t *testing.T) {
defer expectPanic(t, parseError)
Convey(func() {})
}
func TestParseRegistration_MissingActionFunc(t *testing.T) {
defer expectPanic(t, parseError)
Convey("Hi there", 12345)
}
func TestFailureModeNoContext(t *testing.T) {
Convey("Foo", t, func() {
done := make(chan int, 1)
go func() {
defer func() { done <- 1 }()
defer expectPanic(t, noStackContext)
So(len("I have no context"), ShouldBeGreaterThan, 0)
}()
<-done
})
}
func TestFailureModeDuplicateSuite(t *testing.T) {
Convey("cool", t, func() {
defer expectPanic(t, multipleIdenticalConvey)
Convey("dup", nil)
Convey("dup", nil)
})
}
func TestFailureModeIndeterminentSuiteNames(t *testing.T) {
defer expectPanic(t, differentConveySituations)
name := "bob"
Convey("cool", t, func() {
for i := 0; i < 3; i++ {
Convey(name, func() {})
name += "bob"
}
})
}
func TestFailureModeNestedIndeterminentSuiteNames(t *testing.T) {
defer expectPanic(t, differentConveySituations)
name := "bob"
Convey("cool", t, func() {
Convey("inner", func() {
for i := 0; i < 3; i++ {
Convey(name, func() {})
name += "bob"
}
})
})
}
func TestFailureModeParameterButMissing(t *testing.T) {
defer expectPanic(t, parseError)
prepare()
Convey("Foobar", t, FailureHalts)
}
func TestFailureModeParameterWithAction(t *testing.T) {
prepare()
Convey("Foobar", t, FailureHalts, func() {})
}
func TestExtraConveyParameters(t *testing.T) {
defer expectPanic(t, parseError)
prepare()
Convey("Foobar", t, FailureHalts, func() {}, "This is not supposed to be here")
}
func TestExtraConveyParameters2(t *testing.T) {
defer expectPanic(t, parseError)
prepare()
Convey("Foobar", t, func() {}, "This is not supposed to be here")
}
func TestExtraConveyParameters3(t *testing.T) {
defer expectPanic(t, parseError)
output := prepare()
Convey("A", t, func() {
output += "A "
Convey("B", func() {
output += "B "
}, "This is not supposed to be here")
})
expectEqual(t, "A ", output)
}
|