MCPcopy
hub / github.com/grafana/dskit / TestEncodeNodeMetadata_ValidationErrors

Function TestEncodeNodeMetadata_ValidationErrors

kv/memberlist/node_meta_test.go:51–73  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

49}
50
51func TestEncodeNodeMetadata_ValidationErrors(t *testing.T) {
52 tests := []struct {
53 name string
54 role NodeRole
55 zone string
56 wantErr string
57 }{
58 {
59 name: "zone too long",
60 role: NodeRoleMember,
61 zone: "0123456789abcdef0", // 17 bytes
62 wantErr: "zone name too long",
63 },
64 }
65
66 for _, tt := range tests {
67 t.Run(tt.name, func(t *testing.T) {
68 _, err := EncodeNodeMetadata(tt.role, tt.zone)
69 require.Error(t, err)
70 assert.Contains(t, err.Error(), tt.wantErr)
71 })
72 }
73}
74
75func TestEncodedNodeMetadata_ZeroAllocations(t *testing.T) {
76 encoded, err := EncodeNodeMetadata(NodeRoleBridge, "zone-a")

Callers

nothing calls this directly

Calls 3

EncodeNodeMetadataFunction · 0.85
RunMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected