transfer.sh/vendor/github.com/golang/mock/gomock/call_test.go

52 lines
967 B
Go
Raw Normal View History

2019-03-17 20:19:56 +01:00
package gomock
import (
"testing"
)
type mockTestReporter struct {
errorCalls int
fatalCalls int
}
func (o *mockTestReporter) Errorf(format string, args ...interface{}) {
o.errorCalls++
}
func (o *mockTestReporter) Fatalf(format string, args ...interface{}) {
o.fatalCalls++
}
func (o *mockTestReporter) Helper() {}
func TestCall_After(t *testing.T) {
t.Run("SelfPrereqCallsFatalf", func(t *testing.T) {
tr1 := &mockTestReporter{}
c := &Call{t: tr1}
c.After(c)
if tr1.fatalCalls != 1 {
t.Errorf("number of fatal calls == %v, want 1", tr1.fatalCalls)
}
})
t.Run("LoopInCallOrderCallsFatalf", func(t *testing.T) {
tr1 := &mockTestReporter{}
tr2 := &mockTestReporter{}
c1 := &Call{t: tr1}
c2 := &Call{t: tr2}
c1.After(c2)
c2.After(c1)
if tr1.errorCalls != 0 || tr1.fatalCalls != 0 {
t.Error("unexpected errors")
}
if tr2.fatalCalls != 1 {
t.Errorf("number of fatal calls == %v, want 1", tr2.fatalCalls)
}
})
}