From 5ba8177bf2acbd44676065185797ca69a6ef56bb Mon Sep 17 00:00:00 2001 From: feistel <6742251-feistel@users.noreply.gitlab.com> Date: Thu, 2 Sep 2021 04:26:10 +0000 Subject: refactor: avoid os.Is.. in favor of errors.Is --- internal/serving/disk/symlink/path_test.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'internal/serving') diff --git a/internal/serving/disk/symlink/path_test.go b/internal/serving/disk/symlink/path_test.go index 400432c2..21880efa 100644 --- a/internal/serving/disk/symlink/path_test.go +++ b/internal/serving/disk/symlink/path_test.go @@ -6,6 +6,8 @@ package symlink_test import ( "context" + "errors" + "io/fs" "os" "path/filepath" "runtime" @@ -20,7 +22,7 @@ import ( "gitlab.com/gitlab-org/gitlab-pages/internal/vfs/local" ) -var fs = vfs.Instrumented(&local.VFS{}) +var localFs = vfs.Instrumented(&local.VFS{}) type EvalSymlinksTest struct { // If dest is empty, the path is created; otherwise the dest is symlinked to the path. @@ -70,7 +72,7 @@ func simpleJoin(path ...string) string { } func testEvalSymlinks(t *testing.T, wd, path, want string) { - root, err := fs.Root(context.Background(), wd) + root, err := localFs.Root(context.Background(), wd) require.NoError(t, err) have, err := symlink.EvalSymlinks(context.Background(), root, path) @@ -125,7 +127,7 @@ func TestEvalSymlinksIsNotExist(t *testing.T) { root, _ := testhelpers.TmpDir(t, "symlink_tests") _, err := symlink.EvalSymlinks(context.Background(), root, "notexist") - if !os.IsNotExist(err) { + if !errors.Is(err, fs.ErrNotExist) { t.Errorf("expected the file is not found, got %v\n", err) } @@ -136,7 +138,7 @@ func TestEvalSymlinksIsNotExist(t *testing.T) { defer os.Remove("link") _, err = symlink.EvalSymlinks(context.Background(), root, "link") - if !os.IsNotExist(err) { + if !errors.Is(err, fs.ErrNotExist) { t.Errorf("expected the file is not found, got %v\n", err) } } -- cgit v1.2.3