Skip to content
Snippets Groups Projects
Commit 97747936 authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Merge branch 'XX-4464/RemoteStorage' into 'release'

Xx 4464/remote storage

See merge request !42
parents 81c2cb07 7a76f11e
No related branches found
No related tags found
2 merge requests!42Xx 4464/remote storage,!34Release
......@@ -165,6 +165,24 @@ func GetLastModified(path string) (time.Time, error) {
return info.ModTime(), nil
}
// ReadDir reads the named directory, returning all its directory entries
// sorted by filename.
func ReadDir(path string) ([]string, error) {
entries, err := os.ReadDir(path)
if err != nil {
return nil, err
}
files := make([]string, 0)
for _, entry := range entries {
if !entry.IsDir() {
files = append(files, entry.Name())
}
}
return files, nil
}
// exists checks if a file or directory exists at the specified path and also
// returns the file's FileInfo.
func exists(path string) (os.FileInfo, bool) {
......
......@@ -553,6 +553,20 @@ func TestGetLastModified(t *testing.T) {
require.Equal(t, newLastModified, lastModified)
}
// ReadDir unit test.
func TestReadDir(t *testing.T) {
files, err := ReadDir("./")
require.NoError(t, err)
// NOTE: This test uses the files in the utils package as expected values.
// If at any point files are added or moved, refactor this list
// accordingly.
var expectedFiles = []string{"gen.go", "net.go", "net_test.go",
"privNet.go", "utils.go", "utils_test.go"}
require.Equal(t, expectedFiles, files)
}
// Tests that GetLastModified will update after a write operation to a file.
func TestGetLastModified_Update(t *testing.T) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment