Skip to content

Commit f5df606

Browse files
test(metrics): explicitly check for non-nil writer instead of crash testing
Signed-off-by: abhaygoudannavar <abhaysgoudnvr@gmail.com>
1 parent 05344a3 commit f5df606

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

internal/metrics/metrics_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ func TestZerologMetricsMetadata(t *testing.T) {
5656
func TestZerologMetricsInvalidFileDoesNotPanic(t *testing.T) {
5757
// Provide a path to a directory that definitely does not exist
5858
invalidPath := "/does/not/exist/timestamps.log"
59-
59+
6060
// Create the metrics writer with timestamps enabled but an invalid path
6161
writer := NewZerologMetrics(true, invalidPath, "container-test")
62-
63-
// This call would panic with a nil pointer dereference without the fix.
64-
// With the fix, it will safely execute the mockWriter's no-op Capture().
65-
writer.Capture(TS00)
62+
63+
if writer == nil {
64+
t.Fatal("expected non-nil writer (fallback to mockWriter), got nil")
65+
}
6666
}

0 commit comments

Comments
 (0)