You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With interfaces! ;)
You could create a new interface (and probably some wrappers) with all the required file functions you need and replace the actual type with that in your code. The original struct will implement those instantly and you could re-write the function in your test.
go-locker/locker/fileutils/fileutils_test.go
Line 21 in d551afd
With interfaces! ;)
You could create a new interface (and probably some wrappers) with all the required file functions you need and replace the actual type with that in your code. The original struct will implement those instantly and you could re-write the function in your test.
Example:
https://medium.com/swlh/using-go-interfaces-for-testable-code-d2e11b02dea
(But I would not recommend to start the interface name with I... it's not java or php. :) )
Or: https://nathanleclaire.com/blog/2015/10/10/interfaces-and-composition-for-effective-unit-testing-in-golang/
The text was updated successfully, but these errors were encountered: