dominikbraun / timetrace

A simple CLI for tracking your working time.
Apache License 2.0
668 stars 75 forks source link

proposal for filesystem interface, sample implementation for record.go #178

Open KonstantinGasser opened 2 years ago

KonstantinGasser commented 2 years ago

this is the start of the rolling PR for #121.

in timetrace.go I have defined three interfaces to interact with the filesystem. ProjectFS, RecordFS and ReportFS. The code will compile but not work since the dependency injection is not yet done for the interfaces. In record.go I have changed all current interactions with the fs or the os/ioutil lib with the new recordFS interface.

I'd be happy for feedback on the interfaces and possible unclearness regarding decoupling the fs into multiple interfaces.

KonstantinGasser commented 2 years ago

@dominikbraun one follow-up question I have; If the file-system is separated in multiple interfaces for each resource. What would you suggest could be a "best" way to test the separated components? In the background there still will be one Fs struct implementing all the resource interface. However, there could be separated tests each convening only one resource, was this what you mean by testing the components separately?

dominikbraun commented 2 years ago

@dominikbraun one follow-up question I have; If the file-system is separated in multiple interfaces for each resource. What would you suggest could be a "best" way to test the separated components? In the background there still will be one Fs struct implementing all the resource interface. However, there could be separated tests each convening only one resource, was this what you mean by testing the components separately?

Yes, those tests for the Fs methods should be stateless tests where it doesn't make a difference whether it only implements one of those segregated interfaces or the current "big" Filesystem interface.