MCPcopy Create free account
hub / github.com/goadesign/goa / TestAttributeExprIsRequiredNoDefault

Function TestAttributeExprIsRequiredNoDefault

expr/attribute_test.go:607–656  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

605}
606
607func TestAttributeExprIsRequiredNoDefault(t *testing.T) {
608 cases := map[string]struct {
609 attName string
610 expected bool
611 }{
612 "required and no default value": {
613 attName: "foo",
614 expected: true,
615 },
616 "required and default value": {
617 attName: "bar",
618 expected: false,
619 },
620 "not required": {
621 attName: "baz",
622 expected: false,
623 },
624 }
625
626 attribute := AttributeExpr{
627 Type: &UserTypeExpr{
628 AttributeExpr: &AttributeExpr{
629 Type: &Object{
630 &NamedAttributeExpr{
631 Name: "foo",
632 Attribute: &AttributeExpr{},
633 },
634 &NamedAttributeExpr{
635 Name: "bar",
636 Attribute: &AttributeExpr{
637 DefaultValue: 1,
638 },
639 },
640 &NamedAttributeExpr{
641 Name: "baz",
642 Attribute: &AttributeExpr{},
643 },
644 },
645 Validation: &ValidationExpr{
646 Required: []string{"foo", "bar"},
647 },
648 },
649 },
650 }
651 for k, tc := range cases {
652 if actual := attribute.IsRequiredNoDefault(tc.attName); tc.expected != actual {
653 t.Errorf("%s: got %#v, expected %#v", k, actual, tc.expected)
654 }
655 }
656}
657
658func TestAttributeExprIsPrimitivePointer(t *testing.T) {
659 var (

Callers

nothing calls this directly

Calls 1

IsRequiredNoDefaultMethod · 0.95

Tested by

no test coverage detected