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

Function TestSet

internal/metadata/metadata_test.go:60–88  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

58}
59
60func TestSet(t *testing.T) {
61 tests := []struct {
62 name string
63 addr resolver.Address
64 md metadata.MD
65 }{
66 {
67 name: "unset before",
68 addr: resolver.Address{},
69 md: metadata.Pairs("k", "v"),
70 },
71 {
72 name: "set before",
73 addr: resolver.Address{
74 Attributes: attributes.New(mdKey, mdValue(metadata.Pairs("bef", "ore"))),
75 },
76 md: metadata.Pairs("k", "v"),
77 },
78 }
79 for _, tt := range tests {
80 t.Run(tt.name, func(t *testing.T) {
81 newAddr := Set(tt.addr, tt.md)
82 newMD := Get(newAddr)
83 if !cmp.Equal(newMD, tt.md) {
84 t.Errorf("md after Set() = %v, want %v", newMD, tt.md)
85 }
86 })
87 }
88}
89
90func TestValidate(t *testing.T) {
91 for _, test := range []struct {

Callers

nothing calls this directly

Calls 7

PairsFunction · 0.92
NewFunction · 0.92
mdValueTypeAlias · 0.85
SetFunction · 0.70
GetFunction · 0.70
EqualMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected