(t *testing.T)
| 335 | } |
| 336 | |
| 337 | func TestSelectFieldValidateSettings(t *testing.T) { |
| 338 | testDefaultFieldIdValidation(t, core.FieldTypeSelect) |
| 339 | testDefaultFieldNameValidation(t, core.FieldTypeSelect) |
| 340 | testDefaultFieldHelpValidation[core.SelectField](t) |
| 341 | |
| 342 | app, _ := tests.NewTestApp() |
| 343 | defer app.Cleanup() |
| 344 | |
| 345 | scenarios := []struct { |
| 346 | name string |
| 347 | field func() *core.SelectField |
| 348 | expectErrors []string |
| 349 | }{ |
| 350 | { |
| 351 | "zero minimal", |
| 352 | func() *core.SelectField { |
| 353 | return &core.SelectField{ |
| 354 | Id: "test", |
| 355 | Name: "test", |
| 356 | } |
| 357 | }, |
| 358 | []string{"values"}, |
| 359 | }, |
| 360 | { |
| 361 | "MaxSelect > Values length", |
| 362 | func() *core.SelectField { |
| 363 | return &core.SelectField{ |
| 364 | Id: "test", |
| 365 | Name: "test", |
| 366 | Values: []string{"a", "b"}, |
| 367 | MaxSelect: 3, |
| 368 | } |
| 369 | }, |
| 370 | []string{"maxSelect"}, |
| 371 | }, |
| 372 | { |
| 373 | "MaxSelect <= Values length", |
| 374 | func() *core.SelectField { |
| 375 | return &core.SelectField{ |
| 376 | Id: "test", |
| 377 | Name: "test", |
| 378 | Values: []string{"a", "b"}, |
| 379 | MaxSelect: 2, |
| 380 | } |
| 381 | }, |
| 382 | []string{}, |
| 383 | }, |
| 384 | } |
| 385 | |
| 386 | for _, s := range scenarios { |
| 387 | t.Run(s.name, func(t *testing.T) { |
| 388 | field := s.field() |
| 389 | |
| 390 | collection := core.NewBaseCollection("test_collection") |
| 391 | collection.Fields.Add(field) |
| 392 | |
| 393 | errs := field.ValidateSettings(context.Background(), app, collection) |
| 394 |
nothing calls this directly
no test coverage detected
searching dependent graphs…