I have a wrapper interface that defines a Downloadfile function. The problem is that one of parameters has a random temporary directoriename and the output is a random temporary filename. How do I mock it using https://github.com/golang/mock so I can test the addFile function
var wrapper
func Test(t *testing.T) {
ctrl, _ := gomock.WithContext(context.Background(), t)
defer ctrl.Finish()
m := mock.NewMockWrapperInterface(ctrl)
m.EXPECT().DownloadFile("myfile", "/var/folders/ls/???").Return("/var/folders/ls/???", nil)
wrapper = m
path, err := addFile(myfile, key)
...
}
func addFile(myfile, key) (string, error) {
tmpDirectory := helper.CreateTemporaryDirectory(objectKey)
defer helper.CleanUpDirectory(tmpDirectory)
return wrapper.DownloadFile(myfile, tmpDirectory)
}