Refactor trace package tests for improved readability

- Removed unnecessary blank lines in multiple test files to enhance code clarity and maintainability.
- Adjusted formatting in `subscription.go`, `trace_bench_test.go`, `trace_concurrent_test.go`, `trace_mem_test.go`, `trace_node_test.go`, `trace_space_test.go`, and `trace_subscription_test.go` for consistency.
This commit is contained in:
Max 2025-11-18 15:48:21 +08:00
parent 3a46d98663
commit a7210f027f
7 changed files with 13 additions and 19 deletions

View file

@ -37,7 +37,7 @@ func (m *manager) broadcast(update *types.TraceUpdate) {
// Channel was closed, ignore (subscriber cleanup race condition)
}
}()
select {
case ch <- update:
// Sent successfully

View file

@ -491,4 +491,3 @@ func getTraceScenarios() []traceScenario {
},
}
}

View file

@ -80,7 +80,7 @@ func TestConcurrentSpaceOperations(t *testing.T) {
// Concurrent writes to the SAME space (now thread-safe with per-space locks)
var wg sync.WaitGroup
numWorkers := 10
for i := 0; i < numWorkers; i++ {
wg.Add(1)
go func(idx int) {
@ -282,4 +282,3 @@ func TestConcurrentLogging(t *testing.T) {
})
}
}

View file

@ -618,4 +618,3 @@ func TestGoroutineLeak(t *testing.T) {
t.Logf("✓ No goroutine leak detected")
}
}

View file

@ -211,4 +211,3 @@ func TestCompleteWithOutput(t *testing.T) {
})
}
}

View file

@ -176,11 +176,10 @@ func TestSpaceGetSpace(t *testing.T) {
assert.Equal(t, "Test description", retrieved.Description)
assert.Equal(t, int64(7200), retrieved.TTL)
// Get non-existent space (returns nil, nil)
nonExistent, err := manager.GetSpace("nonexistent")
assert.NoError(t, err)
assert.Nil(t, nonExistent)
// Get non-existent space (returns nil, nil)
nonExistent, err := manager.GetSpace("nonexistent")
assert.NoError(t, err)
assert.Nil(t, nonExistent)
})
}
}

View file

@ -153,15 +153,15 @@ func TestSubscribeFrom(t *testing.T) {
// Channel closed
break collectLoop
}
receivedUpdates = append(receivedUpdates, update)
// Check if we received step 2 events
if update.Type == types.UpdateTypeNodeStart {
if data, ok := update.Data.(*types.NodeStartData); ok {
if data.Node != nil && data.Node.Label == "Finalizing" {
foundStep2 = true
receivedUpdates = append(receivedUpdates, update)
// Check if we received step 2 events
if update.Type == types.UpdateTypeNodeStart {
if data, ok := update.Data.(*types.NodeStartData); ok {
if data.Node != nil && data.Node.Label == "Finalizing" {
foundStep2 = true
}
}
}
}
// Stop after receiving trace_complete
if update.Type == types.UpdateTypeComplete {
break collectLoop
@ -280,4 +280,3 @@ func TestMultipleSubscribers(t *testing.T) {
})
}
}