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:
authorSami Hiltunen <shiltunen@gitlab.com>2021-10-11 13:37:24 +0300
committerSami Hiltunen <shiltunen@gitlab.com>2021-10-11 13:43:40 +0300
commit2460642042bc0d6f63383a9e0a0cd512dcff33d7 (patch)
tree7c501d502336f76769897cd444cb73345559f1da
parent77973a9929443a2139963a867f56cd7f5c4adc94 (diff)
Fix TestReplicatorInvalidSourceRepository test
TestReplicatorInvalidSourceRepository test hasn't been working correctly as it does not assert a record exists for the repository prior to deleting the record and asserting a record doesn't exist. SetGeneration was updated earlier not to create records in the 'repositories' table anymore. Since then, the SetGeneration call in the test hasn't been enough to create the database record the test expects to delete. This commit fixes the issue by replacing the 'SetGeneration' call with a 'CreateRepository' call that creates the database record and asserts the record actually exists prior to testing the deletion.
-rw-r--r--internal/praefect/replicator_pg_test.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/internal/praefect/replicator_pg_test.go b/internal/praefect/replicator_pg_test.go
index a1eccbed3..557977661 100644
--- a/internal/praefect/replicator_pg_test.go
+++ b/internal/praefect/replicator_pg_test.go
@@ -51,11 +51,17 @@ func TestReplicatorInvalidSourceRepository(t *testing.T) {
defer testhelper.MustClose(t, targetCC)
rs := datastore.NewPostgresRepositoryStore(glsql.NewDB(t), nil)
- require.NoError(t, rs.SetGeneration(ctx, "virtual-storage-1", "relative-path-1", "gitaly-1", 0))
+
+ require.NoError(t, rs.CreateRepository(ctx, 1, "virtual-storage-1", "relative-path-1", "gitaly-1", nil, nil, true, false))
+
+ exists, err := rs.RepositoryExists(ctx, "virtual-storage-1", "relative-path-1")
+ require.NoError(t, err)
+ require.True(t, exists)
r := &defaultReplicator{rs: rs, log: testhelper.DiscardTestLogger(t)}
require.NoError(t, r.Replicate(ctx, datastore.ReplicationEvent{
Job: datastore.ReplicationJob{
+ RepositoryID: 1,
VirtualStorage: "virtual-storage-1",
RelativePath: "relative-path-1",
SourceNodeStorage: "gitaly-1",
@@ -63,7 +69,7 @@ func TestReplicatorInvalidSourceRepository(t *testing.T) {
},
}, nil, targetCC))
- exists, err := rs.RepositoryExists(ctx, "virtual-storage-1", "relative-path-1")
+ exists, err = rs.RepositoryExists(ctx, "virtual-storage-1", "relative-path-1")
require.NoError(t, err)
require.False(t, exists)
}