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

Function TestAttributeExprHasTag

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

Source from the content-addressed store, hash-verified

821}
822
823func TestAttributeExprHasTag(t *testing.T) {
824 var (
825 tag = "view"
826 )
827 cases := map[string]struct {
828 attribute *AttributeExpr
829 tag string
830 expected bool
831 }{
832 "has tag": {
833 attribute: &AttributeExpr{
834 Type: &Object{
835 &NamedAttributeExpr{
836 Name: "foo",
837 Attribute: &AttributeExpr{
838 Meta: MetaExpr{
839 tag: []string{"default"},
840 },
841 },
842 },
843 },
844 },
845 tag: tag,
846 expected: true,
847 },
848 "attribute expr is nil": {
849 attribute: nil,
850 tag: tag,
851 expected: false,
852 },
853 "not object": {
854 attribute: &AttributeExpr{
855 Type: String,
856 },
857 tag: tag,
858 expected: false,
859 },
860 "object but has no tag": {
861 attribute: &AttributeExpr{
862 Type: &Object{
863 &NamedAttributeExpr{
864 Name: "foo",
865 Attribute: &AttributeExpr{},
866 },
867 },
868 },
869 tag: tag,
870 },
871 }
872
873 for k, tc := range cases {
874 if actual := tc.attribute.HasTag(tc.tag); tc.expected != actual {
875 t.Errorf("%s: got %#v, expected %#v", k, actual, tc.expected)
876 }
877 }
878}
879
880func TestAttributeExprHasTagPrefix(t *testing.T) {

Callers

nothing calls this directly

Calls 1

HasTagMethod · 0.80

Tested by

no test coverage detected