(t *testing.T)
| 201 | } |
| 202 | |
| 203 | func 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 | |
| 235 | func TestCreate_secretKeyEmpty(t *testing.T) { |
| 236 | c := DefaultLANConfig() |
nothing calls this directly
no test coverage detected
searching dependent graphs…