Skip to content

Commit 66f0575

Browse files
tests(testopenai): add wait before server close to ensure cassette recording completes
Signed-off-by: Hrushikesh Patil <[email protected]>
1 parent bc18d95 commit 66f0575

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tests/internal/testopenai/cassettes_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"net/http"
1313
"os"
1414
"testing"
15+
"time"
1516

1617
"github.com/stretchr/testify/require"
1718
)
@@ -27,7 +28,12 @@ func testNewRequest[R any](t *testing.T, tests []cassetteTestCase[R]) {
2728
// documented way to backfill cassettes.
2829
server, err := NewServer(os.Stdout, 0)
2930
require.NoError(t, err)
30-
defer server.Close()
31+
defer func() {
32+
// this sleep is required to wait till large cassettes are recorded
33+
// remove this sleep when we have a way to wait for cassettes to be recorded
34+
<-time.After(5 * time.Second)
35+
server.Close()
36+
}()
3137

3238
baseURL := server.URL()
3339

0 commit comments

Comments
 (0)