newService is a test helper that constructs the internal service struct directly, bypassing the config/env parsing of NewService but still resolving common dimensions like device_id and invocation_id.
(flusher func(SendTelemetryPayload), additionalDimensions ghtelemetry.Dimensions)
| 45 | // directly, bypassing the config/env parsing of NewService but still |
| 46 | // resolving common dimensions like device_id and invocation_id. |
| 47 | func newService(flusher func(SendTelemetryPayload), additionalDimensions ghtelemetry.Dimensions) *service { |
| 48 | deviceID, err := deviceIDFunc() |
| 49 | if err != nil { |
| 50 | deviceID = "<unknown>" |
| 51 | } |
| 52 | |
| 53 | commonDimensions := ghtelemetry.Dimensions{ |
| 54 | "device_id": deviceID, |
| 55 | "invocation_id": uuid.NewString(), |
| 56 | } |
| 57 | maps.Copy(commonDimensions, additionalDimensions) |
| 58 | |
| 59 | return &service{ |
| 60 | flush: flusher, |
| 61 | commonDimensions: commonDimensions, |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | func TestGetOrCreateDeviceID(t *testing.T) { |
| 66 | t.Run("creates new ID on first call", func(t *testing.T) { |
no test coverage detected