/usr/share/gocode/src/github.com/smartystreets/goconvey/reporting/gotest_test.go is in golang-github-smartystreets-goconvey-dev 1.5.0-1.
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 | package reporting
import "testing"
func TestReporterReceivesSuccessfulReport(t *testing.T) {
reporter := NewGoTestReporter()
test := &fakeTest{}
reporter.BeginStory(NewStoryReport(test))
reporter.Report(NewSuccessReport())
if test.failed {
t.Errorf("Should have have marked test as failed--the report reflected success.")
}
}
func TestReporterReceivesFailureReport(t *testing.T) {
reporter := NewGoTestReporter()
test := &fakeTest{}
reporter.BeginStory(NewStoryReport(test))
reporter.Report(NewFailureReport("This is a failure."))
if !test.failed {
t.Errorf("Test should have been marked as failed (but it wasn't).")
}
}
func TestReporterReceivesErrorReport(t *testing.T) {
reporter := NewGoTestReporter()
test := &fakeTest{}
reporter.BeginStory(NewStoryReport(test))
reporter.Report(NewErrorReport("This is an error."))
if !test.failed {
t.Errorf("Test should have been marked as failed (but it wasn't).")
}
}
func TestReporterIsResetAtTheEndOfTheStory(t *testing.T) {
defer catch(t)
reporter := NewGoTestReporter()
test := &fakeTest{}
reporter.BeginStory(NewStoryReport(test))
reporter.EndStory()
reporter.Report(NewSuccessReport())
}
func catch(t *testing.T) {
if r := recover(); r != nil {
t.Log("Getting to this point means we've passed (because we caught a panic appropriately).")
}
}
type fakeTest struct {
failed bool
}
func (self *fakeTest) Fail() {
self.failed = true
}
|