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:
Diffstat (limited to 'cmd/praefect/subcmd_remove_repository_test.go')
-rw-r--r--cmd/praefect/subcmd_remove_repository_test.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/cmd/praefect/subcmd_remove_repository_test.go b/cmd/praefect/subcmd_remove_repository_test.go
index bf2ece389..6e920ec0e 100644
--- a/cmd/praefect/subcmd_remove_repository_test.go
+++ b/cmd/praefect/subcmd_remove_repository_test.go
@@ -4,6 +4,7 @@ import (
"bytes"
"flag"
"fmt"
+ "os"
"path/filepath"
"strings"
"testing"
@@ -158,6 +159,38 @@ func TestRemoveRepository_Exec(t *testing.T) {
assert.Contains(t, out.String(), "Repository found on the following gitaly nodes:")
assert.Contains(t, out.String(), fmt.Sprintf("Attempting to remove %s from the database, and delete it from all gitaly nodes...\n", repo.RelativePath))
assert.Contains(t, out.String(), fmt.Sprintf("Successfully removed %s from", repo.RelativePath))
+ assert.NotContains(t, out.String(), fmt.Sprintf("Did not remove %s from", repo.RelativePath))
+
+ var repositoryRowExists bool
+ require.NoError(t, db.QueryRow(
+ `SELECT EXISTS(SELECT FROM repositories WHERE virtual_storage = $1 AND relative_path = $2)`,
+ cmd.virtualStorage, cmd.relativePath,
+ ).Scan(&repositoryRowExists))
+ require.False(t, repositoryRowExists)
+ })
+
+ t.Run("repository doesnt exist on one gitaly", func(t *testing.T) {
+ var out bytes.Buffer
+ repo := createRepo(t, ctx, repoClient, praefectStorage, t.Name())
+
+ require.NoError(t, os.RemoveAll(filepath.Join(g2Cfg.Storages[0].Path, repo.RelativePath)))
+
+ cmd := &removeRepository{
+ logger: testhelper.NewDiscardingLogger(t),
+ virtualStorage: repo.StorageName,
+ relativePath: repo.RelativePath,
+ dialTimeout: time.Second,
+ apply: true,
+ w: &writer{w: &out},
+ }
+ require.NoError(t, cmd.Exec(flag.NewFlagSet("", flag.PanicOnError), conf))
+
+ require.NoDirExists(t, filepath.Join(g1Cfg.Storages[0].Path, repo.RelativePath))
+ require.NoDirExists(t, filepath.Join(g2Cfg.Storages[0].Path, repo.RelativePath))
+ assert.Contains(t, out.String(), "Repository found in the database.\n")
+ assert.Contains(t, out.String(), "Repository found on the following gitaly nodes: gitaly-1")
+ assert.Contains(t, out.String(), fmt.Sprintf("Attempting to remove %s from the database, and delete it from all gitaly nodes...\n", repo.RelativePath))
+ assert.Contains(t, out.String(), fmt.Sprintf("Successfully removed %s from gitaly-1", repo.RelativePath))
var repositoryRowExists bool
require.NoError(t, db.QueryRow(