Skip to content

Commit e2a72ad

Browse files
authored
Merge branch 'main' into copilot/review-go-sdk-module
2 parents feea20d + 98ac2f6 commit e2a72ad

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

internal/logger/jsonl_logger_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,6 @@ func TestInitJSONLLoggerWithInvalidPath(t *testing.T) {
380380

381381
func TestLogRPCMessageJSONLDirectionTypes(t *testing.T) {
382382
require := require.New(t)
383-
assert := assert.New(t)
384383
tmpDir := t.TempDir()
385384
logDir := filepath.Join(tmpDir, "logs")
386385

@@ -422,19 +421,20 @@ func TestLogRPCMessageJSONLDirectionTypes(t *testing.T) {
422421

423422
for _, tt := range tests {
424423
t.Run(tt.name, func(t *testing.T) {
424+
a := assert.New(t)
425425
testPayload := []byte(`{"jsonrpc":"2.0","id":1}`)
426426

427427
// Clear previous log file
428428
logPath := filepath.Join(logDir, "test.jsonl")
429429
os.Remove(logPath)
430430

431-
LogRPCMessageJSONL(tt.direction, tt.msgType, "test-server", "test-method", testPayload, nil)
431+
// Re-init logger for each subtest
432432
CloseJSONLLogger()
433+
err := InitJSONLLogger(logDir, "test.jsonl")
434+
require.NoError(err, "Re-init failed")
433435

434-
// Re-init for next iteration
435-
if t.Name() != tests[len(tests)-1].name {
436-
InitJSONLLogger(logDir, "test.jsonl")
437-
}
436+
LogRPCMessageJSONL(tt.direction, tt.msgType, "test-server", "test-method", testPayload, nil)
437+
CloseJSONLLogger()
438438

439439
// Read and verify
440440
content, err := os.ReadFile(logPath)
@@ -445,8 +445,8 @@ func TestLogRPCMessageJSONLDirectionTypes(t *testing.T) {
445445
var entry JSONLRPCMessage
446446
json.Unmarshal(content, &entry)
447447

448-
assert.Equal(tt.expected["direction"], entry.Direction, "Direction should match")
449-
assert.Equal(tt.expected["type"], entry.Type, "Type should match")
448+
a.Equal(tt.expected["direction"], entry.Direction, "Direction should match")
449+
a.Equal(tt.expected["type"], entry.Type, "Type should match")
450450
})
451451
}
452452
}

0 commit comments

Comments
 (0)