Closed howieyuen closed 4 years ago
When I used gomonkey write test case in win10 platform, mocked os.RemoveAll() and it worked, but in Ubuntu14.04 and Ubuntu16.04, not worked. Please take a look at this case, see if it is a bug.
below is my test code and screenshot of test results.
package test import ( "fmt" "os" "testing" "github.com/agiledragon/gomonkey" ) func Test_RemoveAll(t *testing.T) { patch := gomonkey.NewPatches() patch.ApplyFunc(os.RemoveAll, func(_ string) error { fmt.Println("use mock functions to do rm -rf") return nil }) defer patch.Reset() doRemove("") } func doRemove(path string) { if err := os.RemoveAll(path); err != nil { fmt.Println(err) } }
win10 result
ubuntu14.04 result
go test -v -gcflags=all=-l
Please refer to the first of the Notes
Many thanks!Sorry,I thought the node only refers to inline writing style function。
When I used gomonkey write test case in win10 platform, mocked os.RemoveAll() and it worked, but in Ubuntu14.04 and Ubuntu16.04, not worked. Please take a look at this case, see if it is a bug.
below is my test code and screenshot of test results.
win10 result![image](https://user-images.githubusercontent.com/23924124/66831543-7f31b480-ef8a-11e9-9523-52195dd0d184.png)
ubuntu14.04 result![image](https://user-images.githubusercontent.com/23924124/66831569-8d7fd080-ef8a-11e9-8b26-1ce4d82b6aa1.png)