Skip to content

Commit

Permalink
Add random numbering to the loadfile test (#203)
Browse files Browse the repository at this point in the history
* Add random numbering to the loadfile test

* Ignore linter error

* Improvements

* Fix linter error

* Address review comments

* Inline variable

* Inline variable
  • Loading branch information
jaredoconnell authored Aug 22, 2024
1 parent 5ef0c20 commit aa02243
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions loadfile/loadfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,18 @@ func Test_LoadContext(t *testing.T) {
assert.NoError(t, os.MkdirAll(testdir, os.ModePerm))

// create a directory
dirname := "mydir"
dirpath := filepath.Join(testdir, dirname)
assert.NoError(t, os.MkdirAll(dirpath, os.ModePerm))
dirPath, err := os.MkdirTemp(testdir, "mydir")
assert.NoError(t, err)

// create a file
filename := "myfile"
filePath := filepath.Join(testdir, filename)
f, err := os.Create(filepath.Clean(filePath))
f, err := os.CreateTemp(dirPath, "myfile")
assert.NoError(t, err)
filePath := f.Name()
assert.NoError(t, f.Close())

// create symlink to the directory
symlinkDirname := dirname + "_sym"
symlinkDirpath := filepath.Join(testdir, symlinkDirname)
assert.NoError(t, os.Symlink(dirpath, symlinkDirpath))
symlinkDirname := dirPath + "_sym"
assert.NoError(t, os.Symlink(dirPath, symlinkDirname))

// create symlink to the file
symlinkFilepath := filePath + "_sym"
Expand All @@ -62,7 +59,7 @@ func Test_LoadContext(t *testing.T) {
errFileRead := "reading file"
// error on loading a directory
neededFiles = map[string]string{
dirpath: dirpath,
dirPath: dirPath,
}
fc, err = loadfile.NewFileCacheUsingContext(testdir, neededFiles)
assert.NoError(t, err)
Expand All @@ -72,7 +69,7 @@ func Test_LoadContext(t *testing.T) {

// error on loading a symlink directory
neededFiles = map[string]string{
symlinkDirpath: symlinkDirpath,
symlinkDirname: symlinkDirname,
}
fc, err = loadfile.NewFileCacheUsingContext(testdir, neededFiles)
assert.NoError(t, err)
Expand Down

0 comments on commit aa02243

Please sign in to comment.