I would just start a server on 127.0.0.1 and have it provide the expected 
responses. This is simple and straightforward, and gives a much better 
test; end-to-end.

The less mocking the better from my point of view. 

If you have to, you would simply wrap the existing structs, creating a 
higher layer that abstracts. Instead of going below, go above.
On Friday, March 31, 2023 at 8:24:14 AM UTC-5 Inian Vasanth wrote:

> Hello Community,
>
> I'm testing out some code for increasing code coverage of our repository, 
> i.e. to maximum level possible. One of the methods I'm dealing with are few 
> methods in standard library (ssh, sftp) that need to be modified for custom 
> behavior.
>
> See Goplay snippet here - https://go.dev/play/p/DGYUqgEKKXh
>
> Basically, I want to modify the type definition of `sshDialer` and 
> `sftpNewClient` to return an interface that is implemented by the native 
> type. If I could do this,  I would generate a mock struct satisfying the 
> same interface and then perform our tests. 
>
> I know mocking standard libraries are not the best of choice, but this is 
> just to get familiar with the language and an experiment with it. 
>
> Also would appreciate other ways to solve the same problem. Thanks
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/aa3b7ac7-0724-4303-a5bc-4c1708e85cfcn%40googlegroups.com.

Reply via email to