MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / TestContext

Function TestContext

pkg/component/component_test.go:239–263  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

237}
238
239func 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}

Callers

nothing calls this directly

Calls 6

NewFunction · 0.92
GetLoggerFunction · 0.92
AddContextFillerMethod · 0.80
NewMethod · 0.65
FillContextMethod · 0.65
ValueMethod · 0.45

Tested by

no test coverage detected