(t *testing.T)
| 24 | ) |
| 25 | |
| 26 | func TestWithCreationState(t *testing.T) { |
| 27 | testCases := []struct { |
| 28 | name string |
| 29 | parentCtx context.Context |
| 30 | }{ |
| 31 | { |
| 32 | name: "nil context", |
| 33 | parentCtx: nil, |
| 34 | }, |
| 35 | { |
| 36 | name: "any context", |
| 37 | parentCtx: context.Background(), |
| 38 | }, |
| 39 | { |
| 40 | name: "context with creation state", |
| 41 | parentCtx: context.WithValue(context.Background(), ctxCreationStateContextKey, newCreationState()), |
| 42 | }, |
| 43 | } |
| 44 | |
| 45 | for _, tc := range testCases { |
| 46 | t.Run(tc.name, func(t *testing.T) { |
| 47 | // given |
| 48 | |
| 49 | // when |
| 50 | result := withCreationState(tc.parentCtx) |
| 51 | |
| 52 | // then |
| 53 | require.NotNil(t, result) |
| 54 | |
| 55 | state := creationStateFromContext(result) |
| 56 | assert.NotNil(t, state) |
| 57 | }) |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | func TestCreationStateFromContext(t *testing.T) { |
| 62 | // given |
nothing calls this directly
no test coverage detected