News for hackers. Stuff that matters.
Re:Things you probably don't know about Go (2012) [slides] by justwalt on Thursday October 10, 2019 @12:15PM (#21216246)
> 6. Mock out the file system

Does anyone know if this is possible to do in Rust? I’ve been searching the last couple of days and I think my biggest problem is not knowing what combination of search terms to use.

Re:Things you probably don't know about Go (2012) [slides] by steveklabnik on Thursday October 10, 2019 @01:59PM (#21217419)
If your functions take Read or Write, you can pass in something else, like memory, instead.

If it doesn’t expose that the whole way up through your test layer that can be tough, of course.

Re:Things you probably don't know about Go (2012) [slides] by arve0 on Thursday October 10, 2019 @12:47PM (#21216649)
I went to lib.rs, searched for mock and found this: https://lib.rs/crates/filesystem
Re:Things you probably don't know about Go (2012) [slides] by justwalt on Thursday October 10, 2019 @01:50PM (#21217351)
Well, I certainly knew about the filesystem crate before, but never thought to see if it offered this functionality. Thanks for this.
Re:Things you probably don't know about Go (2012) [slides] by novok on Friday October 11, 2019 @02:17AM (#21221985)
In swift you make an interface / protocol that represents your filesystem API and then make an adapter that implements that API to the actual filesystem and swap with a mock when necessary. If the library you are using uses the filesystem directly, then you might need to make a similar interface adapter for the library.
Re:Things you probably don't know about Go (2012) [slides] by sneak on Thursday October 10, 2019 @04:01PM (#21218584)
Not an answer to your question, but this is what I use for Go when I need to do this:

https://github.com/spf13/afero