Skip to content

Commit 67d8a47

Browse files
committed
fix test
1 parent 6eb21be commit 67d8a47

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

monkey.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func PatchInstanceMethod(target reflect.Type, methodName string, replacement int
6464
panic(fmt.Sprintf("unknown method %s", methodName))
6565
}
6666

67-
o := &opt{}
67+
o := &opt{global: true}
6868
r := reflect.ValueOf(replacement)
6969
patchValue(m.Func, r, o)
7070
return &PatchGuard{m.Func, r, o}

monkey_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ func (f *f) No() bool { return false }
9090
func TestOnInstanceMethod(t *testing.T) {
9191
i := &f{}
9292
assert(t, !i.No())
93-
monkey.PatchInstanceMethod(reflect.TypeOf(i), "No", func(_ *f) bool { return true })
93+
pg := monkey.PatchInstanceMethod(reflect.TypeOf(i), "No", func(_ *f) bool { return true })
9494
assert(t, i.No())
95-
assert(t, monkey.UnpatchInstanceMethod(reflect.TypeOf(i), "No"))
95+
pg.Unpatch()
9696
assert(t, !i.No())
9797
}
9898

0 commit comments

Comments
 (0)