Open andrehoong-pixieset opened 3 months ago
Your mock is wrong, it should look like this:
func (m *MockS3Interface) GetObject(input *s3.GetObjectInput) (*s3.GetObjectOutput, error) {
args := m.Called(input)
return args.Get(0).(*s3.GetObjectOutput), args.Error(1)
}
And MockS3Interface
should have no fields.
Hey guys I have this test:
Which is implementing this mocked function:
I notice that the expected return value is not actually being enforced. IE: my MockS3Interface is given the error "something went wrong on download", but the expected error to be returned is "aaaaa" (defined after the .On call). Even though the expected return "aaaa" differs from what is actually returned the test still passes
I know I can do something like
args := m.Called(input)
to get the values defined in.Return()
but shouldn't the expected return values also be enforced similar to how the arguments passed intoOn()
are.I'm still a noob when it comes to Golang and mocking so this might just be a misunderstanding on my end, but any insight is greatly appreciated. Thanks in advance!