(t *testing.T)
| 537 | } |
| 538 | |
| 539 | func TestAttributeExprAllRequired(t *testing.T) { |
| 540 | cases := map[string]struct { |
| 541 | typ DataType |
| 542 | expected []string |
| 543 | }{ |
| 544 | "some required": { |
| 545 | typ: &UserTypeExpr{ |
| 546 | AttributeExpr: &AttributeExpr{ |
| 547 | Validation: &ValidationExpr{ |
| 548 | Required: []string{"foo", "bar"}, |
| 549 | }, |
| 550 | }, |
| 551 | }, |
| 552 | expected: []string{"foo", "bar"}, |
| 553 | }, |
| 554 | "no required": { |
| 555 | typ: Boolean, |
| 556 | expected: nil, |
| 557 | }, |
| 558 | } |
| 559 | |
| 560 | for k, tc := range cases { |
| 561 | attribute := AttributeExpr{ |
| 562 | Type: tc.typ, |
| 563 | } |
| 564 | if actual := attribute.AllRequired(); len(tc.expected) != len(actual) { |
| 565 | t.Errorf("%s: expected the number of all required values to match %d got %d ", k, len(tc.expected), len(actual)) |
| 566 | } else { |
| 567 | for i, v := range actual { |
| 568 | if v != tc.expected[i] { |
| 569 | t.Errorf("%s: got %#v, expected %#v at index %d", k, v, tc.expected[i], i) |
| 570 | } |
| 571 | } |
| 572 | } |
| 573 | } |
| 574 | } |
| 575 | |
| 576 | func TestAttributeExprIsRequired(t *testing.T) { |
| 577 | cases := map[string]struct { |
nothing calls this directly
no test coverage detected