MCPcopy
hub / github.com/hashicorp/memberlist / TestCreate_secretKey

Function TestCreate_secretKey

memberlist_test.go:203–233  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

201}
202
203func TestCreate_secretKey(t *testing.T) {
204 cases := []struct {
205 name string
206 key []byte
207 err bool
208 }{
209 {"size-0", make([]byte, 0), false},
210 {"abc", []byte("abc"), true},
211 {"size-16", make([]byte, 16), false},
212 {"size-38", make([]byte, 38), true},
213 }
214
215 for _, tc := range cases {
216 t.Run(tc.name, func(t *testing.T) {
217 c := DefaultLANConfig()
218 c.BindAddr = getBindAddr().String()
219 c.SecretKey = tc.key
220
221 m, err := Create(c)
222 if err == nil {
223 require.NoError(t, m.Shutdown())
224 }
225
226 if tc.err && err == nil {
227 t.Fatalf("Should've failed with key: %#v", tc.key)
228 } else if !tc.err && err != nil {
229 t.Fatalf("Key '%#v' error: %s", tc.key, err)
230 }
231 })
232 }
233}
234
235func TestCreate_secretKeyEmpty(t *testing.T) {
236 c := DefaultLANConfig()

Callers

nothing calls this directly

Calls 6

DefaultLANConfigFunction · 0.85
getBindAddrFunction · 0.85
CreateFunction · 0.85
FatalfMethod · 0.80
ShutdownMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…