add try-extend variant

This commit is contained in:
Jay
2026-05-10 09:59:22 -04:00
parent ad04a920fd
commit 03c783ba53
3 changed files with 29 additions and 1 deletions
+11
View File
@@ -80,6 +80,17 @@ func TestExtend(t *testing.T) {
}
})
t.Run("try passes through", func(t *testing.T) {
inCtx := context.Background()
outCtx, err := TryExtend(inCtx, "subcomponent")
if err != nil {
t.Fatal("unexpected error:", err)
}
if outCtx != inCtx {
t.Errorf("expected context to pass through")
}
})
t.Run("must variant should panic", func(t *testing.T) {
assertPanics(t, func() {
MustExtend(context.Background(), "subcomponent")