Skip to content

Commit

Permalink
Fix flaky DB list repos test (#2959)
Browse files Browse the repository at this point in the history
  • Loading branch information
eleftherias authored Apr 5, 2024
1 parent 85e1cc7 commit 2f59882
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions internal/db/repositories_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,14 @@ func TestGetRepositoryByRepoNameNoProvider(t *testing.T) {
org := createRandomOrganization(t)
project := createRandomProject(t, org.ID)
prov := createRandomProvider(t, project.ID)
createRandomRepository(t, project.ID, prov)
repo1 := createRandomRepository(t, project.ID, prov)

// Create repositories with hardcoded repo IDs because the random ID generation was still causing collisions
createRandomRepository(t, project.ID, prov, func(r *CreateRepositoryParams) {
r.RepoID = int64(100)
})
repo1 := createRandomRepository(t, project.ID, prov, func(r *CreateRepositoryParams) {
r.RepoID = int64(200)
})

repo2, err := testQueries.GetRepositoryByRepoName(context.Background(), GetRepositoryByRepoNameParams{
RepoOwner: repo1.RepoOwner,
Expand Down Expand Up @@ -228,10 +234,9 @@ func TestListRepositoriesByProjectIDAndProvider(t *testing.T) {
project := createRandomProject(t, org.ID)
otherProv := createRandomProvider(t, otherProject.ID)
prov := createRandomProvider(t, project.ID)
createRandomRepository(t, project.ID, otherProv)
createRandomRepository(t, otherProject.ID, prov)
createRandomRepository(t, otherProject.ID, otherProv)

for i := 1001; i < 1020; i++ {
for i := 2001; i < 2010; i++ {
createRandomRepository(t, project.ID, prov, func(r *CreateRepositoryParams) {
r.RepoID = int64(i)
})
Expand Down

0 comments on commit 2f59882

Please sign in to comment.