Skip to content

Commit 4f66540

Browse files
committed
fix: address review comments in tests
- Use t.Context() instead of context.Background() - Remove unnecessary defer in goroutine, call w.Close() directly Signed-off-by: nikos.nikolakakis <[email protected]>
1 parent 9f9b770 commit 4f66540

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

runner/test_test.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package runner
22

33
import (
4-
"context"
54
"os"
65
"path/filepath"
76
"testing"
@@ -72,14 +71,12 @@ deny contains msg if {
7271
"name": "test"
7372
}
7473
}`
75-
go func() {
76-
defer w.Close()
77-
w.Write([]byte(testInput))
78-
}()
74+
w.Write([]byte(testInput))
75+
w.Close()
7976
defer func() { os.Stdin = oldStdin }()
8077

8178
// Run the test
82-
ctx := context.Background()
79+
ctx := t.Context()
8380
results, err := runner.Run(ctx, fileList)
8481
if err != nil {
8582
t.Fatalf("Run failed: %v", err)
@@ -140,7 +137,7 @@ metadata:
140137
}
141138

142139
// Run with a regular file (not stdin)
143-
ctx := context.Background()
140+
ctx := t.Context()
144141
results, err := runner.Run(ctx, []string{configFile})
145142
if err != nil {
146143
t.Fatalf("Run failed: %v", err)

0 commit comments

Comments
 (0)