package bouncer import "testing" func TestContextCredentialRoundTrip(t *testing.T) { if _, ok := Credential(t.Context()); ok { t.Fatal("empty context must have no credential") } if _, ok := Credential(nil); ok { t.Fatal("nil context must have no credential") } token := &struct{ Name string }{Name: "parity"} got, ok := Credential(WithCredential(t.Context(), token)) if !ok || got != token { t.Fatalf("got %#v ok=%t", got, ok) } got, ok = Credential(WithCredential(nil, token)) if !ok || got != token { t.Fatalf("nil ctx got %#v ok=%t", got, ok) } }