Skip to content

Commit

Permalink
Increase entropy of repo ID generation for tests (#1717)
Browse files Browse the repository at this point in the history
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
```
  • Loading branch information
JAORMX authored Nov 23, 2023
1 parent c063e24 commit 868d3bd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/db/repositories_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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
}
Expand Down

0 comments on commit 868d3bd

Please sign in to comment.