Context-related tests.
(t *testing.T)
| 52 | |
| 53 | // Context-related tests. |
| 54 | func TestEventMetadataWithGet(t *testing.T) { |
| 55 | ctx := context.Background() |
| 56 | event := &CLIAnalyticsEventMetadata{ |
| 57 | UserID: "user-id", |
| 58 | InvocationID: "invocation-id", |
| 59 | OS: "os", |
| 60 | CLIVersion: "cli-version", |
| 61 | CommandPath: "command-path", |
| 62 | CommandFlags: []string{"flag1", "flag2"}, |
| 63 | AppID: "app-id", |
| 64 | ConfiguredApplicationsNb: 1, |
| 65 | } |
| 66 | newCtx := WithEventMetadata(ctx, event) |
| 67 | |
| 68 | // Check that the event is correctly set in the context. |
| 69 | require.Equal(t, event, GetEventMetadata(newCtx)) |
| 70 | } |
| 71 | |
| 72 | func TestEventMetadata_DoesNotExistsInContext(t *testing.T) { |
| 73 | ctx := context.Background() |
nothing calls this directly
no test coverage detected