tests: Add tests for snapshot compatibility and recovery between versions

This commit is contained in:
Marek Siarkowicz
2022-03-02 17:09:22 +01:00
parent ae57fe5d30
commit 3ffa253516
3 changed files with 213 additions and 1 deletions

View File

@ -17,6 +17,7 @@ package fileutil
import (
"fmt"
"io"
"io/fs"
"os"
"path/filepath"
@ -165,3 +166,16 @@ func RemoveMatchFile(lg *zap.Logger, dir string, matchFunc func(fileName string)
}
return nil
}
// ListFiles lists files if matchFunc is true on an existing dir
// Returns error if the dir does not exist
func ListFiles(dir string, matchFunc func(fileName string) bool) ([]string, error) {
var files []string
err := filepath.Walk(dir, func(path string, info fs.FileInfo, err error) error {
if matchFunc(path) {
files = append(files, path)
}
return nil
})
return files, err
}