Skip to content

Commit

Permalink
remove flake test
Browse files Browse the repository at this point in the history
  • Loading branch information
uv-orbs committed May 2, 2022
1 parent 98e61c7 commit b88f20a
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions utils/try_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package utils
import (
"context"
"fmt"
"github.com/stretchr/testify/require"
"sync/atomic"
"testing"
"time"

"github.com/stretchr/testify/require"
)

func TestTry(t *testing.T) {
Expand All @@ -26,16 +27,18 @@ func TestTry(t *testing.T) {
require.EqualValues(t, 3, *iPtr, "should attempt to execute 3 times")
}

func TestTryWithCancelledContext(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
defer cancel()
// this test is flaky on circle CI
// Why test go core functionality?
// func TestTryWithCancelledContext(t *testing.T) {
// ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
// defer cancel()

err := Try(ctx, 100, 10*time.Millisecond, 1*time.Millisecond, func(ctxWithTimeout context.Context) error {
return fmt.Errorf("no!")
})
// err := Try(ctx, 100, 10*time.Second, 1*time.Second, func(ctxWithTimeout context.Context) error {
// return fmt.Errorf("no!")
// })

require.EqualError(t, err, "context deadline exceeded after 7 attempts")
}
// require.EqualError(t, err, "context deadline exceeded after 7 attempts")
// }

func TestTryWithError(t *testing.T) {
var iPtr *int32
Expand Down

0 comments on commit b88f20a

Please sign in to comment.