(t *testing.T)
| 395 | } |
| 396 | |
| 397 | func TestFieldsListStringAndValue(t *testing.T) { |
| 398 | t.Run("empty list", func(t *testing.T) { |
| 399 | testFieldsList := core.NewFieldsList() |
| 400 | |
| 401 | str := testFieldsList.String() |
| 402 | if str != "[]" { |
| 403 | t.Fatalf("Expected empty slice, got\n%q", str) |
| 404 | } |
| 405 | |
| 406 | v, err := testFieldsList.Value() |
| 407 | if err != nil { |
| 408 | t.Fatal(err) |
| 409 | } |
| 410 | if v != str { |
| 411 | t.Fatalf("Expected String and Value to match") |
| 412 | } |
| 413 | }) |
| 414 | |
| 415 | t.Run("list with fields", func(t *testing.T) { |
| 416 | testFieldsList := core.NewFieldsList( |
| 417 | &core.TextField{Id: "f1id", Name: "test1"}, |
| 418 | &core.BoolField{Id: "f2id", Name: "test2"}, |
| 419 | &core.URLField{Id: "f3id", Name: "test3"}, |
| 420 | ) |
| 421 | |
| 422 | str := testFieldsList.String() |
| 423 | |
| 424 | v, err := testFieldsList.Value() |
| 425 | if err != nil { |
| 426 | t.Fatal(err) |
| 427 | } |
| 428 | if v != str { |
| 429 | t.Fatalf("Expected String and Value to match") |
| 430 | } |
| 431 | |
| 432 | expectedParts := []string{ |
| 433 | `"type":"bool"`, |
| 434 | `"type":"url"`, |
| 435 | `"type":"text"`, |
| 436 | `"id":"f1id"`, |
| 437 | `"id":"f2id"`, |
| 438 | `"id":"f3id"`, |
| 439 | `"name":"test1"`, |
| 440 | `"name":"test2"`, |
| 441 | `"name":"test3"`, |
| 442 | } |
| 443 | |
| 444 | for _, part := range expectedParts { |
| 445 | if !strings.Contains(str, part) { |
| 446 | t.Fatalf("Missing %q in\nn%v", part, str) |
| 447 | } |
| 448 | } |
| 449 | }) |
| 450 | } |
| 451 | |
| 452 | func TestFieldsListScan(t *testing.T) { |
| 453 | scenarios := []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…