Open fasmat opened 2 years ago
Hey @fasmat,
I just figured out that current runners doesn't support fs.FS
, so this issue would be a great enhancement.
What I have in mind is a single NewRunner(fs.FS)
:
NewRunner(fstest.MapFS{})
NewRunner(os.DirFS("."))
That said DryRunner
and WetRunner
could be kept, but they will just call NewRunner
with the appropriate fs
.
What do you think ?
EDIT: seems like I went a little too fast, fs.FS
is only a readable interface, so it cannot be used by a runner. Maybe this will change in the future.
genny v2 could be improved imho by making the API feel more like one is writing go code using the standard library instead of an abstraction of such. This issue serves as a collection of sorts for those API proposals:
remove all usages of
packr
With the
io/fs
package introduced in go 1.16 we can remove all usages ofpackr
and replace them with their new equivalents.genny.Runner
should not change behavior after instantiationAll fields of
genny.Runner
should be private to ensure they are only set during instantiation of the object and not modified afterwards. Provide a New function with options likeWithLogger
,WithExecFn
, etc. to set those fields.WithDisk
can be used bygentest.NewRunner
to return a runner for testing together with a reference to the virtual disk for seeding.genny.Runner
should abstract usage of virtual / real filesThe disk object represents a virtual file system that is used in a dry run to simulate the actual file system. It should not be accessed from outside
genny.Runner
to prevent the user from thinking that modifying the disk actually changes something on the hard drive when a wet runner is used. Instead most of it's functionality will be added togenny.Runner:
gentest
package updatesTo make it easier to setup a virtual filesystem in tests now
gentest.NewRunner()
returns access to the internal disk of the runner that is used for testing:implementation of
io/fs
interfacesDisk
should implement the following interfaces;Runner
should probably implement most of these interfaces too:Returned virtual files and directories should implement the
io/fs
interfaces like theiros
equivalents: