blob: d5d4d16505891f4388242a22b5a45bf77c7ef51a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
package testhelpers
import (
"context"
"path/filepath"
"testing"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitlab-pages/internal/vfs"
"gitlab.com/gitlab-org/gitlab-pages/internal/vfs/local"
)
var fs = vfs.Instrumented(&local.VFS{})
func TmpDir(tb testing.TB) (vfs.Root, string) {
tb.Helper()
var err error
tmpDir := tb.TempDir()
// On some systems `/tmp` can be a symlink
tmpDir, err = filepath.EvalSymlinks(tmpDir)
require.NoError(tb, err)
root, err := fs.Root(context.Background(), tmpDir, "")
require.NoError(tb, err)
return root, tmpDir
}
|