Skip to content

Commit

Permalink
fix(client): unflake Marker List test
Browse files Browse the repository at this point in the history
  • Loading branch information
jharley committed Apr 9, 2024
1 parent 6b168f6 commit 6b97fc5
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions client/marker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package client_test
import (
"context"
"fmt"
"slices"
"testing"
"time"

Expand Down Expand Up @@ -43,10 +44,19 @@ func TestMarkers(t *testing.T) {
})

t.Run("List", func(t *testing.T) {
markers, err := c.Markers.List(ctx, dataset)

require.NoError(t, err)
assert.Contains(t, markers, *m, "could not find newly created marker with List")
// this has proven to be a bit racey after the create above, so we'll retry a few times
assert.EventuallyWithT(t, func(col *assert.CollectT) {
ml, err := c.Markers.List(ctx, dataset)
require.NoError(col, err)

// not doing an Equal here because the timestamps may be different
// and confirming the ID is in the listing is sufficient
assert.Condition(col, func() bool {
return slices.ContainsFunc(ml, func(cm client.Marker) bool {
return cm.ID == m.ID
})
})
}, time.Second, 200*time.Millisecond, "could not find newly created Marker in List")
})

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

0 comments on commit 6b97fc5

Please sign in to comment.