Skip to content

Commit 4743ffd

Browse files
test: fix flaky test
1 parent ab37c7b commit 4743ffd

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

jsonschema/oas3/inline_timeout_test.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"errors"
66
"testing"
7-
"time"
87

98
"github.com/speakeasy-api/openapi/jsonschema/oas3"
109
"github.com/stretchr/testify/assert"
@@ -19,12 +18,9 @@ func TestInline_ContextTimeout_Error(t *testing.T) {
1918
Type: oas3.NewTypeFromString("string"),
2019
})
2120

22-
// Create a context that times out immediately
23-
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Nanosecond)
24-
defer cancel()
25-
26-
// Wait for context to timeout
27-
time.Sleep(1 * time.Millisecond)
21+
// Create a context that is already cancelled to ensure deterministic behavior
22+
ctx, cancel := context.WithCancel(context.Background())
23+
cancel() // Cancel immediately to ensure context is cancelled before Inline is called
2824

2925
opts := oas3.InlineOptions{
3026
ResolveOptions: oas3.ResolveOptions{

0 commit comments

Comments
 (0)