(t *testing.T)
| 311 | } |
| 312 | |
| 313 | func TestAdminConfigValidates(t *testing.T) { |
| 314 | tests := []struct { |
| 315 | name string |
| 316 | cfg func(*Config) // resorting to using a function as a param because of internal composite structs |
| 317 | err string |
| 318 | }{ |
| 319 | { |
| 320 | "Timeout", |
| 321 | func(cfg *Config) { |
| 322 | cfg.Admin.Timeout = 0 |
| 323 | }, |
| 324 | "Admin.Timeout must be > 0", |
| 325 | }, |
| 326 | } |
| 327 | |
| 328 | for i, test := range tests { |
| 329 | c := NewTestConfig() |
| 330 | test.cfg(c) |
| 331 | err := c.Validate() |
| 332 | var target ConfigurationError |
| 333 | if !errors.As(err, &target) || string(target) != test.err { |
| 334 | t.Errorf("[%d]:[%s] Expected %s, Got %s\n", i, test.name, test.err, err) |
| 335 | } |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | func TestProducerConfigValidates(t *testing.T) { |
| 340 | tests := []struct { |
nothing calls this directly
no test coverage detected