Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfeistel <6742251-feistel@users.noreply.gitlab.com>2021-10-08 23:04:00 +0300
committerfeistel <6742251-feistel@users.noreply.gitlab.com>2022-01-24 17:39:46 +0300
commit3c8b844011a8a7cf18c7589900ba7f12b2ebf570 (patch)
tree925d6dbeafb06f18a045d0574b8c4487f79797a7 /internal/vfs
parent136471e8d5a582236fb0f9565da3b0114a048b1e (diff)
test: replace tmpdir workaround with native T tmp
Diffstat (limited to 'internal/vfs')
-rw-r--r--internal/vfs/local/root_test.go3
-rw-r--r--internal/vfs/local/vfs_test.go13
2 files changed, 6 insertions, 10 deletions
diff --git a/internal/vfs/local/root_test.go b/internal/vfs/local/root_test.go
index e7bbb63f..094a48c0 100644
--- a/internal/vfs/local/root_test.go
+++ b/internal/vfs/local/root_test.go
@@ -123,8 +123,7 @@ func TestReadlinkAbsolutePath(t *testing.T) {
// /tmp/dir: directory
// /tmp/dir/symlink: points to `/tmp/file` outside of the `/tmp/dir`
// /tmp/dir/symlink2: points to `/tmp/dir/file`
- tmpDir, cleanup := tmpDir(t)
- defer cleanup()
+ tmpDir := tmpDir(t)
dirPath := filepath.Join(tmpDir, "dir")
err := os.Mkdir(dirPath, 0755)
diff --git a/internal/vfs/local/vfs_test.go b/internal/vfs/local/vfs_test.go
index e9b3fe71..fd36dd4c 100644
--- a/internal/vfs/local/vfs_test.go
+++ b/internal/vfs/local/vfs_test.go
@@ -14,17 +14,15 @@ import (
var localVFS = &VFS{}
-func tmpDir(t *testing.T) (string, func()) {
- tmpDir, err := os.MkdirTemp("", "vfs")
- require.NoError(t, err)
+func tmpDir(t *testing.T) string {
+ var err error
+ tmpDir := t.TempDir()
// On some systems `/tmp` can be a symlink
tmpDir, err = filepath.EvalSymlinks(tmpDir)
require.NoError(t, err)
- return tmpDir, func() {
- os.RemoveAll(tmpDir)
- }
+ return tmpDir
}
func TestVFSRoot(t *testing.T) {
@@ -35,8 +33,7 @@ func TestVFSRoot(t *testing.T) {
// /tmp/file: file
// /tmp/file_link: symlink to `file`
// /tmp/file_absolute_link: symlink to `/tmp/file`
- tmpDir, cleanup := tmpDir(t)
- defer cleanup()
+ tmpDir := tmpDir(t)
dirPath := filepath.Join(tmpDir, "dir")
err := os.Mkdir(dirPath, 0755)