My tests keep failing with but no actual calls happened
but I am positive the func is getting called (It's a logging function so I see the logs on the terminal)
Basically I have code that looks something like this :
common/utils.go
func LogNilValue(ctx string){
log.Logger.Warn(ctx)
}
main.go
import (
"common/utils"
)
func CheckFunc(*string value) {
ctx := "Some context string"
if value == nil {
utils.LogNilValue(ctx) //void func that just logs the string
}
}
test.go
type MyMockedObject struct{
mock.Mock
}
func TestNil() {
m := new(MyMockedObject)
m.Mock.On("LogNilValue", mock.Anything).Return(nil)
CheckFunc(nil)
m.AssertCalled(s.T(), "LogNilValue", mock.Anything)
}
I expect this to work but then, I keep getting no actual calls happened
. Not sure what I am doing wrong here.