Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add random numbering to the loadfile test #203

Merged
merged 7 commits into from
Aug 22, 2024
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions loadfile/loadfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,20 @@ 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))
dirPrefix := "mydir"
dirPath, err := os.MkdirTemp(testdir, dirPrefix)
jaredoconnell marked this conversation as resolved.
Show resolved Hide resolved
assert.NoError(t, err)

// create a file
filename := "myfile"
filePath := filepath.Join(testdir, filename)
f, err := os.Create(filepath.Clean(filePath))
filenamePrefix := "myfile"
f, err := os.CreateTemp(dirPath, filenamePrefix)
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 +61,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 +71,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
Loading