Skip to content

Commit

Permalink
Merge pull request #127 from dushaoshuai/fix-testing
Browse files Browse the repository at this point in the history
testing: fix testing for ApplyPrivateMethod
  • Loading branch information
agiledragon committed Apr 30, 2023
2 parents ff1b5f4 + 38116e3 commit 6a89ed8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions test/apply_private_method_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package test

import (
"github.com/agiledragon/gomonkey/v2/test/fake"
"testing"

. "github.com/agiledragon/gomonkey/v2"
"github.com/agiledragon/gomonkey/v2/test/fake"

. "github.com/smartystreets/goconvey/convey"

. "github.com/agiledragon/gomonkey/v2"
)

func TestApplyPrivateMethod(t *testing.T) {
Expand All @@ -24,11 +26,11 @@ func TestApplyPrivateMethod(t *testing.T) {
Convey("patch private value method in the different package", func() {
s := fake.PrivateMethodStruct{}
patches := ApplyPrivateMethod(s, "haveEaten", func(_ fake.PrivateMethodStruct) bool {
return false
return true
})
defer patches.Reset()
result := s.AreYouHungry()
So(result, ShouldEqual, "I am hungry")
So(result, ShouldEqual, "I am full")
})

Convey("repeat patch same method", func() {
Expand Down

0 comments on commit 6a89ed8

Please sign in to comment.