Anyone have an opinion on gomock

107 views
Skip to first unread message

Fraser Scott

unread,
Feb 4, 2016, 4:10:47 AM2/4/16
to pki.io
I've started writing tests for the controllers, but most of the code requires reading/writing to the filesystem etc. 

Does anyone have any experience or opinions on using gomock? Is it helpful or unnecessary for mocking filesystem logic? The alternative would be to actually test using the real filesystem, like we're doing for the admin integration tests.

Cheers

Jon Bonazza

unread,
Feb 4, 2016, 8:25:57 PM2/4/16
to Fraser Scott, pki.io

I prefer the testify package. It has a mocking suite. I dont have first hand experience with gomock though.


--
You received this message because you are subscribed to the Google Groups "pki.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pki_io+un...@googlegroups.com.
To post to this group, send email to pki...@googlegroups.com.
Visit this group at https://groups.google.com/group/pki_io.
To view this discussion on the web, visit https://groups.google.com/d/msgid/pki_io/16c13f7a-2607-4bb7-aca8-ae17775527cf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Fraser Scott

unread,
Feb 5, 2016, 3:27:26 AM2/5/16
to pki.io, fraser...@gmail.com
On Friday, 5 February 2016 01:25:57 UTC, Jon Bonazza wrote:

I prefer the testify package. It has a mocking suite. I dont have first hand experience with gomock though.


Fair enough. Thinking about it, any mocking would need to be able to persist information throughout a test because our heavy use of the file system. So a test might need to create a config file first (using a previously tested function), then test the actual processing of the config file in some way. 

Fraser Scott

unread,
Feb 5, 2016, 4:19:45 AM2/5/16
to pki.io, fraser...@gmail.com
This looks promising: https://github.com/blang/vfs

Jon Bonazza

unread,
Feb 5, 2016, 12:35:24 PM2/5/16
to Fraser Scott, pki.io

Ideally,  the code would be laid out in a way that promotes easy mocking of input (from file for example) using interfaces (for instance, pass around io.Reader interfaces instead of file paths), but for times when this just isn't practical, creating dummy files in the TMPDIR before a test is common.


On Fri, Feb 5, 2016, 1:19 AM Fraser Scott <fraser...@gmail.com> wrote:
This looks promising: https://github.com/blang/vfs

--
You received this message because you are subscribed to the Google Groups "pki.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pki_io+un...@googlegroups.com.
To post to this group, send email to pki...@googlegroups.com.
Visit this group at https://groups.google.com/group/pki_io.
Reply all
Reply to author
Forward
0 new messages