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

Function TestAttributeExprHasTagPrefix

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

Source from the content-addressed store, hash-verified

878}
879
880func TestAttributeExprHasTagPrefix(t *testing.T) {
881 var (
882 tag = "security:apikey:api_key"
883 prefix = "security:apikey"
884 )
885 cases := map[string]struct {
886 attribute *AttributeExpr
887 prefix string
888 expected bool
889 }{
890 "has tag prefix": {
891 attribute: &AttributeExpr{
892 Type: &Object{
893 &NamedAttributeExpr{
894 Name: "foo",
895 Attribute: &AttributeExpr{
896 Meta: MetaExpr{
897 tag: []string{"key"},
898 },
899 },
900 },
901 },
902 },
903 prefix: prefix,
904 expected: true,
905 },
906 "attribute expr is nil": {
907 attribute: nil,
908 prefix: prefix,
909 expected: false,
910 },
911 "not object": {
912 attribute: &AttributeExpr{
913 Type: String,
914 },
915 prefix: prefix,
916 expected: false,
917 },
918 "object but has no tag": {
919 attribute: &AttributeExpr{
920 Type: &Object{
921 &NamedAttributeExpr{
922 Name: "foo",
923 Attribute: &AttributeExpr{},
924 },
925 },
926 },
927 prefix: prefix,
928 },
929 }
930
931 for k, tc := range cases {
932 if actual := tc.attribute.HasTagPrefix(tc.prefix); tc.expected != actual {
933 t.Errorf("%s: got %#v, expected %#v", k, actual, tc.expected)
934 }
935 }
936}
937

Callers

nothing calls this directly

Calls 1

HasTagPrefixMethod · 0.80

Tested by

no test coverage detected