Skip to content

Commit

Permalink
fixes parallel testing of list identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
Dopeamin committed Sep 23, 2024
1 parent ed8f85d commit 4be5493
Showing 1 changed file with 34 additions and 11 deletions.
45 changes: 34 additions & 11 deletions tests/integration/identifier/identifier_complete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,42 @@ func TestIdentifierOperations(t *testing.T) {

t.Run("ListIdentifiers", func(t *testing.T) {
t.Run("All", func(t *testing.T) {
// List identifiers
initialList, err := integration.SDK(t).Identifiers().List(ctx, []string{}, "", 1, 100)
assert.NoError(t, err)
assert.NotNil(t, initialList)

// Create new identifier
integration.CreateIdentifier(t)

// List identifiers containing new identifier
newList, err := integration.SDK(t).Identifiers().List(ctx, []string{}, "", 1, 100)
assert.NoError(t, err)
assert.NotNil(t, newList)
assert.Equal(t, newList.Paging.TotalItems, initialList.Paging.TotalItems+1)
newIdentifier := integration.CreateIdentifier(t)

var allIdentifiers []api.Identifier
page := 1
pageSize := 100
hasNextPage := true

for hasNextPage {
// List identifiers for the current page
list, err := integration.SDK(t).Identifiers().List(ctx, []string{}, "", page, pageSize)
assert.NoError(t, err)
assert.NotNil(t, list)

// Append identifiers to the complete list
allIdentifiers = append(allIdentifiers, list.Identifiers...)

// Check if there's a next page
if list.Paging.TotalPages <= page {
hasNextPage = false
} else {
page++
}
}

// Search for the new identifier in the list
found := false
for _, identifier := range allIdentifiers {
if identifier.IdentifierID == newIdentifier {
found = true
break
}
}

assert.True(t, found, "New identifier should be found in the list")
})

t.Run("ByValueAndType", func(t *testing.T) {
Expand Down

0 comments on commit 4be5493

Please sign in to comment.