(t *testing.T)
| 294 | } |
| 295 | |
| 296 | func TestNewServiceLogModeFlushesToWriter(t *testing.T) { |
| 297 | // Given an invocation with log delivery |
| 298 | t.Cleanup(stubDeviceID("test-device")) |
| 299 | var buf bytes.Buffer |
| 300 | service := NewService(LogFlusher(&buf, false)) |
| 301 | |
| 302 | // When the invocation finishes |
| 303 | service.Record(ghtelemetry.Event{ |
| 304 | Type: "test_event", |
| 305 | Dimensions: map[string]string{"key": "value"}, |
| 306 | }) |
| 307 | service.Finish() |
| 308 | |
| 309 | // Then the writer receives the recorded event |
| 310 | output := buf.String() |
| 311 | assert.Contains(t, output, "Telemetry payload:") |
| 312 | assert.Contains(t, output, "test_event") |
| 313 | assert.Contains(t, output, `"key"`) |
| 314 | assert.Contains(t, output, `"value"`) |
| 315 | } |
| 316 | |
| 317 | func TestNewServiceLogModeWithColorLogsToWriter(t *testing.T) { |
| 318 | // Given an invocation with colored log delivery |
nothing calls this directly
no test coverage detected