@@ -380,7 +380,6 @@ func TestInitJSONLLoggerWithInvalidPath(t *testing.T) {
380380
381381func 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