Skip to content

Commit

Permalink
Increate wait time, fix object store test
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrpio committed Dec 5, 2022
1 parent e1ce7c3 commit d448bd9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion test/basic_test.go
Expand Up @@ -56,7 +56,7 @@ func getStableNumGoroutine(t *testing.T) int {

func checkNoGoroutineLeak(t *testing.T, base int, action string) {
t.Helper()
waitFor(t, 5*time.Second, 100*time.Millisecond, func() error {
waitFor(t, 10*time.Second, 100*time.Millisecond, func() error {
delta := (runtime.NumGoroutine() - base)
if delta > 0 {
return fmt.Errorf("%d Go routines still exist after %s", delta, action)
Expand Down
25 changes: 20 additions & 5 deletions test/object_test.go
Expand Up @@ -827,11 +827,26 @@ func TestObjectList(t *testing.T) {
}
})

t.Run("context timeout", func(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Nanosecond)
defer cancel()
_, err := root.List(nats.Context(ctx))
expectErr(t, err, context.DeadlineExceeded)
t.Run("context canceled", func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())

errs := make(chan error)
go func() {
for {
_, err := root.List(nats.Context(ctx))
if err != nil {
errs <- err
}
}
}()
time.Sleep(10 * time.Millisecond)
cancel()
select {
case err := <-errs:
expectErr(t, err, context.Canceled)
case <-time.After(5 * time.Second):
t.Fatal("Expected error, got none")
}
})
}

Expand Down

0 comments on commit d448bd9

Please sign in to comment.