MCPcopy
hub / github.com/grpc/grpc-go / checkOutHeader

Function checkOutHeader

stats/stats_test.go:602–647  ·  view source on GitHub ↗
(t *testing.T, d *gotData, e *expectedData)

Source from the content-addressed store, hash-verified

600}
601
602func checkOutHeader(t *testing.T, d *gotData, e *expectedData) {
603 var (
604 ok bool
605 st *stats.OutHeader
606 )
607 if st, ok = d.s.(*stats.OutHeader); !ok {
608 t.Fatalf("got %T, want OutHeader", d.s)
609 }
610 if d.ctx == nil {
611 t.Fatalf("d.ctx = nil, want <non-nil>")
612 }
613 if st.Compression != e.compression {
614 t.Fatalf("st.Compression = %v, want %v", st.Compression, e.compression)
615 }
616 if d.client {
617 if st.FullMethod != e.method {
618 t.Fatalf("st.FullMethod = %s, want %v", st.FullMethod, e.method)
619 }
620 if st.RemoteAddr.String() != e.serverAddr {
621 t.Fatalf("st.RemoteAddr = %v, want %v", st.RemoteAddr, e.serverAddr)
622 }
623 // additional headers might be injected so instead of testing equality, test that all the
624 // expected headers keys have the expected header values.
625 for key := range testMetadata {
626 if !reflect.DeepEqual(st.Header.Get(key), testMetadata.Get(key)) {
627 t.Fatalf("st.Header[%s] = %v, want %v", key, st.Header.Get(key), testMetadata.Get(key))
628 }
629 }
630
631 if rpcInfo, ok := d.ctx.Value(rpcCtxKey{}).(*stats.RPCTagInfo); ok {
632 if rpcInfo.FullMethodName != st.FullMethod {
633 t.Fatalf("rpcInfo.FullMethod = %s, want %v", rpcInfo.FullMethodName, st.FullMethod)
634 }
635 } else {
636 t.Fatalf("got context %v, want one with rpcCtxKey", d.ctx)
637 }
638 } else {
639 // additional headers might be injected so instead of testing equality, test that all the
640 // expected headers keys have the expected header values.
641 for key := range testHeaderMetadata {
642 if !reflect.DeepEqual(st.Header.Get(key), testHeaderMetadata.Get(key)) {
643 t.Fatalf("st.Header[%s] = %v, want %v", key, st.Header.Get(key), testHeaderMetadata.Get(key))
644 }
645 }
646 }
647}
648
649func checkOutPayload(t *testing.T, d *gotData, e *expectedData) {
650 var (

Callers

nothing calls this directly

Calls 4

FatalfMethod · 0.65
StringMethod · 0.65
GetMethod · 0.65
ValueMethod · 0.45

Tested by

no test coverage detected