(t *testing.T)
| 237 | } |
| 238 | |
| 239 | func TestContext(t *testing.T) { |
| 240 | a := assertions.New(t) |
| 241 | |
| 242 | config := component.Config{} |
| 243 | |
| 244 | c, err := component.New(test.GetLogger(t), &config) |
| 245 | a.So(err, should.BeNil) |
| 246 | |
| 247 | baseCtx := context.Background() |
| 248 | |
| 249 | // Filler |
| 250 | { |
| 251 | c.AddContextFiller(func(ctx context.Context) context.Context { |
| 252 | ctx = context.WithValue(ctx, "k1", "v1") |
| 253 | ctx = context.WithValue(ctx, "k2", "v2") |
| 254 | return ctx |
| 255 | }) |
| 256 | ctx := c.FillContext(baseCtx) |
| 257 | a.So(ctx, should.HaveParentContext, baseCtx) |
| 258 | v1 := ctx.Value("k1") |
| 259 | a.So(v1, should.Equal, "v1") |
| 260 | v2 := ctx.Value("k2") |
| 261 | a.So(v2, should.Equal, "v2") |
| 262 | } |
| 263 | } |
nothing calls this directly
no test coverage detected