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

Function TestAttributeExprIsRequired

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

Source from the content-addressed store, hash-verified

574}
575
576func TestAttributeExprIsRequired(t *testing.T) {
577 cases := map[string]struct {
578 attName string
579 expected bool
580 }{
581 "required": {
582 attName: "foo",
583 expected: true,
584 },
585 "not required": {
586 attName: "bar",
587 expected: false,
588 },
589 }
590
591 for k, tc := range cases {
592 attribute := AttributeExpr{
593 Type: &UserTypeExpr{
594 AttributeExpr: &AttributeExpr{
595 Validation: &ValidationExpr{
596 Required: []string{"foo"},
597 },
598 },
599 },
600 }
601 if actual := attribute.IsRequired(tc.attName); tc.expected != actual {
602 t.Errorf("%s: got %#v, expected %#v", k, actual, tc.expected)
603 }
604 }
605}
606
607func TestAttributeExprIsRequiredNoDefault(t *testing.T) {
608 cases := map[string]struct {

Callers

nothing calls this directly

Calls 1

IsRequiredMethod · 0.95

Tested by

no test coverage detected