Beispiel #1
0
func TestTryMe(t *testing.T) {
	ctrl := gomock.NewController(t)
	defer ctrl.Finish()

	dep.MOCK().SetController(ctrl)
	dep.MOCK().MockAll(true)

	dep.EXPECT().Wibble(1, 2).Return(5)

	ret := TryMe(1, 2)

	if ret != 5 {
		t.Errorf("TryMe returned %d, not 5", ret)
	}
}
Beispiel #2
0
func TestDisableMock(t *testing.T) {
	ctrl := gomock.NewController(t)
	defer ctrl.Finish()

	dep.MOCK().SetController(ctrl)
	dep.MOCK().MockAll(true)
	dep.MOCK().DisableMock("NewFoo")
	dep.MOCK().DisableMock("Foo.Wibble")

	dep.EXPECT().Wibble(1, 2).Return(5)

	ret := TryMe(1, 2)

	if ret != 5 {
		t.Errorf("TryMe returned %d, not 5", ret)
	}

	ret = TryMe3(2, 3)

	if ret != 6 {
		t.Errorf("TryMe returned %d, not 6", ret)
	}
}