(t *testing.T)
| 1083 | } |
| 1084 | |
| 1085 | func TestAttributes(t *testing.T) { |
| 1086 | tests := []struct { |
| 1087 | in string |
| 1088 | expected FieldExpression |
| 1089 | }{ |
| 1090 | {in: "duration", expected: NewIntrinsic(IntrinsicDuration)}, |
| 1091 | {in: "kind", expected: NewIntrinsic(IntrinsicKind)}, |
| 1092 | {in: ".foo", expected: NewAttribute("foo")}, |
| 1093 | {in: ".max", expected: NewAttribute("max")}, |
| 1094 | {in: ".status", expected: NewAttribute("status")}, |
| 1095 | {in: ".kind", expected: NewAttribute("kind")}, |
| 1096 | {in: ".foo.bar", expected: NewAttribute("foo.bar")}, |
| 1097 | {in: ".foo.bar.baz", expected: NewAttribute("foo.bar.baz")}, |
| 1098 | {in: ".foo.3", expected: NewAttribute("foo.3")}, |
| 1099 | {in: ".foo3", expected: NewAttribute("foo3")}, |
| 1100 | {in: ".http_status", expected: NewAttribute("http_status")}, |
| 1101 | {in: ".http-status", expected: NewAttribute("http-status")}, |
| 1102 | {in: ".http+", expected: NewAttribute("http+")}, |
| 1103 | {in: ".😝", expected: NewAttribute("😝")}, |
| 1104 | {in: ".http-other", expected: NewAttribute("http-other")}, |
| 1105 | {in: "parent.duration", expected: NewScopedAttribute(AttributeScopeNone, true, "duration")}, |
| 1106 | {in: "parent.foo.bar.baz", expected: NewScopedAttribute(AttributeScopeNone, true, "foo.bar.baz")}, |
| 1107 | {in: "resource.foo.bar.baz", expected: NewScopedAttribute(AttributeScopeResource, false, "foo.bar.baz")}, |
| 1108 | {in: "span.foo.bar", expected: NewScopedAttribute(AttributeScopeSpan, false, "foo.bar")}, |
| 1109 | {in: "event.foo.bar", expected: NewScopedAttribute(AttributeScopeEvent, false, "foo.bar")}, |
| 1110 | {in: "link.foo.bar", expected: NewScopedAttribute(AttributeScopeLink, false, "foo.bar")}, |
| 1111 | {in: "instrumentation.foo.bar", expected: NewScopedAttribute(AttributeScopeInstrumentation, false, "foo.bar")}, |
| 1112 | {in: "parent.resource.foo", expected: NewScopedAttribute(AttributeScopeResource, true, "foo")}, |
| 1113 | {in: "parent.span.foo", expected: NewScopedAttribute(AttributeScopeSpan, true, "foo")}, |
| 1114 | {in: "parent.resource.foo.bar.baz", expected: NewScopedAttribute(AttributeScopeResource, true, "foo.bar.baz")}, |
| 1115 | {in: "parent.span.foo.bar", expected: NewScopedAttribute(AttributeScopeSpan, true, "foo.bar")}, |
| 1116 | {in: `."bar z".foo`, expected: NewAttribute("bar z.foo")}, |
| 1117 | {in: `span."bar z".foo`, expected: NewScopedAttribute(AttributeScopeSpan, false, "bar z.foo")}, |
| 1118 | {in: `."bar z".foo."bar"`, expected: NewAttribute("bar z.foo.bar")}, |
| 1119 | {in: `.foo."bar baz"`, expected: NewAttribute("foo.bar baz")}, |
| 1120 | {in: `.foo."bar baz".bar`, expected: NewAttribute("foo.bar baz.bar")}, |
| 1121 | {in: `.foo."bar \" baz"`, expected: NewAttribute(`foo.bar " baz`)}, |
| 1122 | {in: `.foo."bar \\ baz"`, expected: NewAttribute(`foo.bar \ baz`)}, |
| 1123 | {in: `.foo."bar \\"." baz"`, expected: NewAttribute(`foo.bar \. baz`)}, |
| 1124 | {in: `."foo.bar"`, expected: NewAttribute(`foo.bar`)}, |
| 1125 | {in: `."🤘"`, expected: NewAttribute(`🤘`)}, |
| 1126 | } |
| 1127 | |
| 1128 | for _, tc := range tests { |
| 1129 | t.Run(tc.in, func(t *testing.T) { |
| 1130 | s := "{ " + tc.in + " }" |
| 1131 | actual, err := Parse(s) |
| 1132 | |
| 1133 | require.NoError(t, err) |
| 1134 | require.Equal(t, newRootExpr(newPipeline(newSpansetFilter(tc.expected))), actual) |
| 1135 | |
| 1136 | s = "{" + tc.in + "}" |
| 1137 | actual, err = Parse(s) |
| 1138 | |
| 1139 | require.NoError(t, err) |
| 1140 | require.Equal(t, newRootExpr(newPipeline(newSpansetFilter(tc.expected))), actual) |
| 1141 | |
| 1142 | s = "{ (" + tc.in + ") }" |
nothing calls this directly
no test coverage detected