Write test case for a function which is invoked by another function?

Hi, I have a use case where my function is being invoked by another function to check for updates. I have written test cases in the past where i test the function which are REST API’s.
I am not sure how do i test this one? Any suggestions?- FYI- i create a mock to test the parent function which mocks an s3 bucket and the child function uses the same bucket. Thanks!

@Contra_Boy you can have mock for the dependent client s3iface.S3API.
If s3iface.S3API is an HTTP server you’re expecting a response from then you can probably run a httptest server and send different responses based on your test cases.

I have a mock of s3API from which i will be sending a mock file and pass it as a body:nil for the function to use. If we dont reference any file it errors out

You cannot edit the content inside a file writer or a buffer inside the mock. If you want to write something inside the buffer you can either abstract the functionality and implement it with a mock concrete type and make it return the data that you want.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.