DeepImage-an-Image-to-Image-technology
DeepImage-an-Image-to-Image-technology copied to clipboard
failpoint not activated
I write this in foo.go:
func pingCapFail() (string, failpoint.Value) {
failpoint.Inject("failpoint-name", func(val failpoint.Value) {
failpoint.Return("unit-test", val)
})
return "success", nil
}
and i run failpoint-ctl enable , code becomes this;
func pingCapFail() (string, failpoint.Value) {
if val, ok := failpoint.Eval(_curpkg_("failpoint-name")); ok {
return "unit-test", val
}
return "success", nil
}
then in foo_test.go ,i write my test code like this:
func Test_pingCapFail(t *testing.T) {
failpoint.Enable("failpoint-name", "return(5)")
got, got1 := pingCapFail()
if got != "unit-test" {
t.Errorf("pingCapFail() got = %v, want %v", got, "unit-test")
}
if !reflect.DeepEqual(got1, 5) {
t.Errorf("pingCapFail() got1 = %v, want %v", got1, 5)
}
}
and it fails, and obviously the failpoint is not activated, can someone tell me why?