From 72f4f45a5d56b43da0ff6d529c15f8203cfc1326 Mon Sep 17 00:00:00 2001 From: Juan Antonio Osorio Date: Thu, 23 Nov 2023 09:26:27 +0200 Subject: [PATCH] Increase entropy of repo ID generation for tests This aims to avoid issues such as: ``` repositories_test.go:166: Error Trace: /home/runner/work/minder/minder/internal/db/repositories_test.go:72 /home/runner/work/minder/minder/internal/db/repositories_test.go:166 Error: Received unexpected error: pq: duplicate key value violates unique constraint "unique_repo_id" Test: TestListRepositoriesByProjectID ``` --- internal/db/repositories_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/db/repositories_test.go b/internal/db/repositories_test.go index 132c30496d..416c52229b 100644 --- a/internal/db/repositories_test.go +++ b/internal/db/repositories_test.go @@ -44,7 +44,7 @@ func createRandomRepository(t *testing.T, project uuid.UUID, prov string, opts . ProjectID: project, RepoOwner: rand.RandomName(seed), RepoName: rand.RandomName(seed), - RepoID: int32(rand.RandomInt(0, 2000, seed)), + RepoID: int32(rand.RandomInt(0, 5000, seed)), IsPrivate: false, IsFork: false, WebhookID: sql.NullInt32{Int32: int32(rand.RandomInt(0, 1000, seed)), Valid: true}, @@ -62,7 +62,7 @@ func createRandomRepository(t *testing.T, project uuid.UUID, prov string, opts . _, err := testQueries.GetRepositoryByRepoID(context.Background(), arg.RepoID) if err != sql.ErrNoRows { seed++ - arg.RepoID = int32(rand.RandomInt(0, 2000, seed)) + arg.RepoID = int32(rand.RandomInt(0, 5000, seed)) } else { break }