예제 #1
0
func Test2TryMe(t *testing.T) {
	ctrl := gomock.NewController(t)
	defer ctrl.Finish()

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

	ret := TryMe(1, 2)

	if ret != 3 {
		t.Errorf("TryMe returned %d, not 3", ret)
	}
}
예제 #2
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)
	}
}
예제 #3
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)
	}
}