I hasten to add, my library sshego makes it pretty easy to spin up and down an sshd. e.g.
https://github.com/glycerine/sshego/blob/master/server_test.go On Friday, March 31, 2023 at 11:20:41 PM UTC-5 Jason E. Aten wrote: > 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/5235d4ef-7992-4a4e-93ec-c71bccf02865n%40googlegroups.com.