Add testing

This commit is contained in:
Melody Becker 2025-04-14 16:59:59 +02:00
parent 3233f8c27f
commit 06e6d457da
Signed by: mstar
SSH key fingerprint: SHA256:9VAo09aaVNTWKzPW7Hq2LW+ox9OdwmTSHRoD4mlz1yI
14 changed files with 273 additions and 5 deletions

View file

@ -14,6 +14,10 @@ type FSWrapper struct {
log bool
}
// Compile time interface implementation assertion
var _ fs.FS = &FSWrapper{}
// No test, as no processing happens, only wrapping the arguments in a struct
func NewFSWrapper(wraps fs.FS, appends string, logAccess bool) *FSWrapper {
return &FSWrapper{
wrapped: wraps,
@ -22,11 +26,12 @@ func NewFSWrapper(wraps fs.FS, appends string, logAccess bool) *FSWrapper {
}
}
func (fs *FSWrapper) Open(name string) (fs.File, error) {
res, err := fs.wrapped.Open(fs.toAdd + name)
if fs.log {
// Pretty sure this can't be reliably tested
func (fw *FSWrapper) Open(name string) (fs.File, error) {
res, err := fw.wrapped.Open(fw.toAdd + name)
if fw.log {
log.Debug().
Str("prefix", fs.toAdd).
Str("prefix", fw.toAdd).
Str("filename", name).
Err(err).
Msg("fswrapper: File access result")