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

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <git@zjvandeweg.nl>2019-09-05 10:39:13 +0300
committerZeger-Jan van de Weg <git@zjvandeweg.nl>2019-09-05 10:39:13 +0300
commit934d09b8fac8301d787ca5322aab90da75b7675d (patch)
treeabdabd3fa950b528b8a9d7d0ba78a23918987969
parent6f8d218de081302e1c7924506992be6b7803f91d (diff)
parenta726ea9c792c8aafad0fb009c3a78af2f84e1edd (diff)
Merge branch 'po-rename-path-assert-helper' into 'master'
Change AssertFileNotExists to AssertPathNotExists See merge request gitlab-org/gitaly!1473
-rw-r--r--internal/cache/walker_test.go2
-rw-r--r--internal/safe/file_writer_test.go2
-rw-r--r--internal/service/namespace/namespace_test.go2
-rw-r--r--internal/service/objectpool/alternates_test.go4
-rw-r--r--internal/service/objectpool/link_test.go4
-rw-r--r--internal/service/repository/cleanup_test.go12
-rw-r--r--internal/service/repository/create_from_snapshot_test.go2
-rw-r--r--internal/service/repository/gc_test.go2
-rw-r--r--internal/service/smarthttp/inforefs_test.go4
-rw-r--r--internal/testhelper/testhelper.go4
10 files changed, 19 insertions, 19 deletions
diff --git a/internal/cache/walker_test.go b/internal/cache/walker_test.go
index efef681b0..97068eaf4 100644
--- a/internal/cache/walker_test.go
+++ b/internal/cache/walker_test.go
@@ -90,7 +90,7 @@ func TestDiskCacheInitialClear(t *testing.T) {
// runs the move-and-clear function
require.NoError(t, config.Validate())
- testhelper.AssertFileNotExists(t, canary)
+ testhelper.AssertPathNotExists(t, canary)
}
func setupDiskCacheWalker(t testing.TB) func() {
diff --git a/internal/safe/file_writer_test.go b/internal/safe/file_writer_test.go
index 5acf484db..293debf24 100644
--- a/internal/safe/file_writer_test.go
+++ b/internal/safe/file_writer_test.go
@@ -27,7 +27,7 @@ func TestFile(t *testing.T) {
_, err = io.Copy(file, bytes.NewBufferString(fileContents))
require.NoError(t, err)
- testhelper.AssertFileNotExists(t, filePath)
+ testhelper.AssertPathNotExists(t, filePath)
require.NoError(t, file.Commit())
diff --git a/internal/service/namespace/namespace_test.go b/internal/service/namespace/namespace_test.go
index 2f63acca4..b93c62325 100644
--- a/internal/service/namespace/namespace_test.go
+++ b/internal/service/namespace/namespace_test.go
@@ -248,7 +248,7 @@ func TestRemoveNamespace(t *testing.T) {
if tc.errorCode == codes.OK {
require.Equal(t, existingStorage, tc.request.StorageName, "sanity check")
- testhelper.AssertFileNotExists(t, filepath.Join(storageDir, tc.request.Name))
+ testhelper.AssertPathNotExists(t, filepath.Join(storageDir, tc.request.Name))
}
})
}
diff --git a/internal/service/objectpool/alternates_test.go b/internal/service/objectpool/alternates_test.go
index 730d0b128..69ed29d69 100644
--- a/internal/service/objectpool/alternates_test.go
+++ b/internal/service/objectpool/alternates_test.go
@@ -57,7 +57,7 @@ func TestDisconnectGitAlternates(t *testing.T) {
// Check that the object can still be found, even though
// objects/info/alternates is gone. This is the purpose of
// DisconnectGitAlternates.
- testhelper.AssertFileNotExists(t, altPath)
+ testhelper.AssertPathNotExists(t, altPath)
testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "cat-file", "-e", existingObjectID)
}
@@ -76,7 +76,7 @@ func TestDisconnectGitAlternatesNoAlternates(t *testing.T) {
altPath, err := git.InfoAlternatesPath(testRepo)
require.NoError(t, err, "find info/alternates")
- testhelper.AssertFileNotExists(t, altPath)
+ testhelper.AssertPathNotExists(t, altPath)
_, err = client.DisconnectGitAlternates(ctx, &gitalypb.DisconnectGitAlternatesRequest{Repository: testRepo})
require.NoError(t, err, "call DisconnectGitAlternates on repository without alternates")
diff --git a/internal/service/objectpool/link_test.go b/internal/service/objectpool/link_test.go
index 19d8fe3f1..ff7acc510 100644
--- a/internal/service/objectpool/link_test.go
+++ b/internal/service/objectpool/link_test.go
@@ -139,7 +139,7 @@ func TestLinkNoClobber(t *testing.T) {
require.NoError(t, pool.Create(ctx, testRepo))
alternatesFile := filepath.Join(testRepoPath, "objects/info/alternates")
- testhelper.AssertFileNotExists(t, alternatesFile)
+ testhelper.AssertPathNotExists(t, alternatesFile)
contentBefore := "mock/objects\n"
require.NoError(t, ioutil.WriteFile(alternatesFile, []byte(contentBefore), 0644))
@@ -215,7 +215,7 @@ func TestUnlink(t *testing.T) {
require.NoError(t, pool.Link(ctx, deletedRepo))
removeDeletedRepo()
- testhelper.AssertFileNotExists(t, deletedRepoPath)
+ testhelper.AssertPathNotExists(t, deletedRepoPath)
pool2, err := objectpool.NewObjectPool(testRepo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
require.NoError(t, err)
diff --git a/internal/service/repository/cleanup_test.go b/internal/service/repository/cleanup_test.go
index 69687c8ee..bb0f2e4e1 100644
--- a/internal/service/repository/cleanup_test.go
+++ b/internal/service/repository/cleanup_test.go
@@ -54,7 +54,7 @@ func TestCleanupDeletesRefsLocks(t *testing.T) {
assert.FileExists(t, keepLockPath)
- testhelper.AssertFileNotExists(t, deleteLockPath)
+ testhelper.AssertPathNotExists(t, deleteLockPath)
}
func TestCleanupDeletesPackedRefsLock(t *testing.T) {
@@ -118,7 +118,7 @@ func TestCleanupDeletesPackedRefsLock(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, c)
- testhelper.AssertFileNotExists(t, lockPath)
+ testhelper.AssertPathNotExists(t, lockPath)
}
})
}
@@ -184,8 +184,8 @@ func TestCleanupDeletesStaleWorktrees(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, c)
- testhelper.AssertFileNotExists(t, worktreeCheckoutPath)
- testhelper.AssertFileNotExists(t, worktreePath)
+ testhelper.AssertPathNotExists(t, worktreeCheckoutPath)
+ testhelper.AssertPathNotExists(t, worktreePath)
}
})
}
@@ -250,7 +250,7 @@ func TestCleanupDisconnectedWorktrees(t *testing.T) {
// cleanup should prune the disconnected worktree administrative files
_, err = client.Cleanup(ctx, req)
require.NoError(t, err)
- testhelper.AssertFileNotExists(t, worktreeAdminPath)
+ testhelper.AssertPathNotExists(t, worktreeAdminPath)
// if the worktree administrative files are pruned, then we should be able
// to checkout another worktree at the same path
@@ -288,6 +288,6 @@ func TestCleanupFileLocks(t *testing.T) {
createFileWithTimes(lockPath, oldTime)
_, err = client.Cleanup(ctx, req)
assert.NoError(t, err)
- testhelper.AssertFileNotExists(t, lockPath)
+ testhelper.AssertPathNotExists(t, lockPath)
}
}
diff --git a/internal/service/repository/create_from_snapshot_test.go b/internal/service/repository/create_from_snapshot_test.go
index a44d53946..2abc1aad5 100644
--- a/internal/service/repository/create_from_snapshot_test.go
+++ b/internal/service/repository/create_from_snapshot_test.go
@@ -217,5 +217,5 @@ func TestCreateRepositoryFromSnapshotHandlesMalformedResponse(t *testing.T) {
require.Nil(t, rsp)
// Ensure that a partial result is not left in place
- testhelper.AssertFileNotExists(t, repoPath)
+ testhelper.AssertPathNotExists(t, repoPath)
}
diff --git a/internal/service/repository/gc_test.go b/internal/service/repository/gc_test.go
index 80ed55a2e..f90a1122e 100644
--- a/internal/service/repository/gc_test.go
+++ b/internal/service/repository/gc_test.go
@@ -164,7 +164,7 @@ func TestGarbageCollectDeletesRefsLocks(t *testing.T) {
assert.FileExists(t, keepLockPath)
- testhelper.AssertFileNotExists(t, deleteLockPath)
+ testhelper.AssertPathNotExists(t, deleteLockPath)
}
func TestGarbageCollectFailure(t *testing.T) {
diff --git a/internal/service/smarthttp/inforefs_test.go b/internal/service/smarthttp/inforefs_test.go
index 0237a6f32..441ec59ab 100644
--- a/internal/service/smarthttp/inforefs_test.go
+++ b/internal/service/smarthttp/inforefs_test.go
@@ -275,7 +275,7 @@ func TestCacheInfoRefsUploadPack(t *testing.T) {
// if feature-flag is disabled, we should not find a cached response
assertNormalResponse()
- testhelper.AssertFileNotExists(t, pathToCachedResponse(t, rpcRequest))
+ testhelper.AssertPathNotExists(t, pathToCachedResponse(t, rpcRequest))
// enable feature flag, and we expect to find the cached response
ctx = enableCacheFeatureFlag(ctx)
@@ -322,7 +322,7 @@ func TestCacheInfoRefsUploadPack(t *testing.T) {
_, err = makeInfoRefsUploadPackRequest(ctx, t, serverSocketPath, invalidReq)
testhelper.RequireGrpcError(t, err, codes.Internal)
- testhelper.AssertFileNotExists(t, pathToCachedResponse(t, invalidReq))
+ testhelper.AssertPathNotExists(t, pathToCachedResponse(t, invalidReq))
}
func createInvalidRepo(t testing.TB, repo *gitalypb.Repository) func() {
diff --git a/internal/testhelper/testhelper.go b/internal/testhelper/testhelper.go
index fd55df70b..e776fb5b2 100644
--- a/internal/testhelper/testhelper.go
+++ b/internal/testhelper/testhelper.go
@@ -472,8 +472,8 @@ func GetRepositoryRefs(t *testing.T, repoPath string) string {
return string(refs)
}
-// AssertFileNotExists asserts true if the file doesn't exist, false otherwise
-func AssertFileNotExists(t *testing.T, path string) {
+// AssertPathNotExists asserts true if the path doesn't exist, false otherwise
+func AssertPathNotExists(t *testing.T, path string) {
_, err := os.Stat(path)
assert.True(t, os.IsNotExist(err), "file should not exist: %s", path)
}