@@ -2,6 +2,7 @@ package reporting
22
33import (
44 "context"
5+ "fmt"
56 "log/slog"
67 "os"
78 "testing"
@@ -44,7 +45,7 @@ func TestErrorAggregator(t *testing.T) {
4445 t .Run ("RecordError" , func (t * testing.T ) {
4546 config := DefaultErrorAggregatorConfig ()
4647 aggregator := NewErrorAggregator (config , logger )
47- defer aggregator .Stop (context .Background ())
48+ defer func () { _ = aggregator .Stop (context .Background ()) }( )
4849
4950 ctx := context .Background ()
5051 execError := & executor.ExecutionError {
@@ -70,7 +71,7 @@ func TestErrorAggregator(t *testing.T) {
7071 t .Run ("GenerateReport" , func (t * testing.T ) {
7172 config := DefaultErrorAggregatorConfig ()
7273 aggregator := NewErrorAggregator (config , logger )
73- defer aggregator .Stop (context .Background ())
74+ defer func () { _ = aggregator .Stop (context .Background ()) }( )
7475
7576 ctx := context .Background ()
7677
@@ -108,7 +109,7 @@ func TestErrorAggregator(t *testing.T) {
108109 t .Run ("ExportData" , func (t * testing.T ) {
109110 config := DefaultErrorAggregatorConfig ()
110111 aggregator := NewErrorAggregator (config , logger )
111- defer aggregator .Stop (context .Background ())
112+ defer func () { _ = aggregator .Stop (context .Background ()) }( )
112113
113114 ctx := context .Background ()
114115
@@ -141,7 +142,7 @@ func TestReportingService(t *testing.T) {
141142 config := DefaultReportingServiceConfig ()
142143 service , err := NewReportingService (config , logger )
143144 require .NoError (t , err )
144- defer service .Stop (context .Background ())
145+ defer func () { _ = service .Stop (context .Background ()) }( )
145146
146147 ctx := context .Background ()
147148 execError := & executor.ExecutionError {
@@ -166,7 +167,7 @@ func TestReportingService(t *testing.T) {
166167 config := DefaultReportingServiceConfig ()
167168 service , err := NewReportingService (config , logger )
168169 require .NoError (t , err )
169- defer service .Stop (context .Background ())
170+ defer func () { _ = service .Stop (context .Background ()) }( )
170171
171172 ctx := context .Background ()
172173
@@ -202,7 +203,7 @@ func TestReportingService(t *testing.T) {
202203 config := DefaultReportingServiceConfig ()
203204 service , err := NewReportingService (config , logger )
204205 require .NoError (t , err )
205- defer service .Stop (context .Background ())
206+ defer func () { _ = service .Stop (context .Background ()) }( )
206207
207208 ctx := context .Background ()
208209
@@ -215,7 +216,7 @@ func TestReportingService(t *testing.T) {
215216 config := DefaultReportingServiceConfig ()
216217 service , err := NewReportingService (config , logger )
217218 require .NoError (t , err )
218- defer service .Stop (context .Background ())
219+ defer func () { _ = service .Stop (context .Background ()) }( )
219220
220221 ctx := context .Background ()
221222
@@ -247,7 +248,7 @@ func TestReportingService(t *testing.T) {
247248 config := DefaultReportingServiceConfig ()
248249 service , err := NewReportingService (config , logger )
249250 require .NoError (t , err )
250- defer service .Stop (context .Background ())
251+ defer func () { _ = service .Stop (context .Background ()) }( )
251252
252253 mockHandler := & MockNotificationHandler {}
253254
@@ -284,7 +285,7 @@ func TestReportingService(t *testing.T) {
284285 config := DefaultReportingServiceConfig ()
285286 service , err := NewReportingService (config , logger )
286287 require .NoError (t , err )
287- defer service .Stop (context .Background ())
288+ defer func () { _ = service .Stop (context .Background ()) }( )
288289
289290 ctx := context .Background ()
290291
@@ -302,7 +303,7 @@ func TestReportingService(t *testing.T) {
302303 config := DefaultReportingServiceConfig ()
303304 service , err := NewReportingService (config , logger )
304305 require .NoError (t , err )
305- defer service .Stop (context .Background ())
306+ defer func () { _ = service .Stop (context .Background ()) }( )
306307
307308 stats := service .GetStats ()
308309 assert .NotNil (t , stats )
@@ -342,6 +343,7 @@ func TestNotificationHandlers(t *testing.T) {
342343 }
343344
344345 handler := NewWebhookNotificationHandler (config , logger )
346+ require .NotNil (t , handler )
345347
346348 notification := & ErrorNotification {
347349 ID : "test-notification" ,
@@ -352,6 +354,10 @@ func TestNotificationHandlers(t *testing.T) {
352354 ErrorCount : 3 ,
353355 }
354356
357+ // Verify notification is properly structured
358+ assert .Equal (t , "test-notification" , notification .ID )
359+ assert .Equal (t , "medium" , notification .Severity )
360+
355361 // This will actually make an HTTP request to httpbin.org
356362 // Comment out if you don't want external requests in tests
357363 // err := handler.SendNotification(context.Background(), notification)
@@ -361,7 +367,7 @@ func TestNotificationHandlers(t *testing.T) {
361367 t .Run ("FileNotificationHandler" , func (t * testing.T ) {
362368 tempDir , err := os .MkdirTemp ("" , "voidrunner-notifications-*" )
363369 require .NoError (t , err )
364- defer os .RemoveAll (tempDir )
370+ defer func () { _ = os .RemoveAll (tempDir ) }( )
365371
366372 handler , err := NewFileNotificationHandler (tempDir , logger )
367373 require .NoError (t , err )
@@ -458,7 +464,7 @@ func TestErrorMetricsAndReports(t *testing.T) {
458464 logger := slog .New (slog .NewTextHandler (os .Stdout , & slog.HandlerOptions {Level : slog .LevelDebug }))
459465 config := DefaultErrorAggregatorConfig ()
460466 aggregator := NewErrorAggregator (config , logger )
461- defer aggregator .Stop (context .Background ())
467+ defer func () { _ = aggregator .Stop (context .Background ()) }( )
462468
463469 ctx := context .Background ()
464470
@@ -523,7 +529,7 @@ func TestErrorMetricsAndReports(t *testing.T) {
523529
524530 service , err := NewReportingService (config , logger )
525531 require .NoError (t , err )
526- defer service .Stop (context .Background ())
532+ defer func () { _ = service .Stop (context .Background ()) }( )
527533
528534 ctx := context .Background ()
529535
0 commit comments