diff --git a/matchers/compliance/compliance_test.go b/matchers/compliance/compliance_test.go index 9178e058b2..705c4c4315 100644 --- a/matchers/compliance/compliance_test.go +++ b/matchers/compliance/compliance_test.go @@ -52,7 +52,58 @@ func TestCompliance(t *testing.T) { skip: true, }, { - input: "{foo=\\\"}", + input: `{foo=\n}`, + want: func() labels.Matchers { + ms := labels.Matchers{} + m, _ := labels.NewMatcher(labels.MatchEqual, "foo", "\n") + return append(ms, m) + }(), + skip: true, + }, + { + input: `{foo=bar\n}`, + want: func() labels.Matchers { + ms := labels.Matchers{} + m, _ := labels.NewMatcher(labels.MatchEqual, "foo", "bar\n") + return append(ms, m) + }(), + skip: true, + }, + { + input: `{foo=\t}`, + want: func() labels.Matchers { + ms := labels.Matchers{} + m, _ := labels.NewMatcher(labels.MatchEqual, "foo", "\\t") + return append(ms, m) + }(), + }, + { + input: `{foo=bar\t}`, + want: func() labels.Matchers { + ms := labels.Matchers{} + m, _ := labels.NewMatcher(labels.MatchEqual, "foo", "bar\\t") + return append(ms, m) + }(), + }, + { + input: `{foo=bar\}`, + want: func() labels.Matchers { + ms := labels.Matchers{} + m, _ := labels.NewMatcher(labels.MatchEqual, "foo", "bar\\") + return append(ms, m) + }(), + }, + { + input: `{foo=bar\\}`, + want: func() labels.Matchers { + ms := labels.Matchers{} + m, _ := labels.NewMatcher(labels.MatchEqual, "foo", "bar\\") + return append(ms, m) + }(), + skip: true, + }, + { + input: `{foo=\"}`, want: func() labels.Matchers { ms := labels.Matchers{} m, _ := labels.NewMatcher(labels.MatchEqual, "foo", "\"") @@ -60,6 +111,15 @@ func TestCompliance(t *testing.T) { }(), skip: true, }, + { + input: `{foo=bar\"}`, + want: func() labels.Matchers { + ms := labels.Matchers{} + m, _ := labels.NewMatcher(labels.MatchEqual, "foo", "bar\"") + return append(ms, m) + }(), + skip: true, + }, { input: `{foo=bar}`, want: func() labels.Matchers { @@ -386,7 +446,7 @@ func TestCompliance(t *testing.T) { t.Fatalf("expected error but got none: %v", tc.err) } if !reflect.DeepEqual(got, tc.want) { - t.Fatalf("labels not equal:\ngot %#v\nwant %#v", got, tc.want) + t.Fatalf("matchers not equal:\ngot %s\nwant %s", got, tc.want) } }) } diff --git a/pkg/labels/parse_test.go b/pkg/labels/parse_test.go index b4b1d631d4..dd1731c9b7 100644 --- a/pkg/labels/parse_test.go +++ b/pkg/labels/parse_test.go @@ -298,6 +298,30 @@ func TestMatchers(t *testing.T) { return append(ms, m) }(), }, + { + input: `{foo=bar\}`, + want: func() []*Matcher { + ms := []*Matcher{} + m, _ := NewMatcher(MatchEqual, "foo", "bar\\") + return append(ms, m) + }(), + }, + { + input: `{foo=bar\\}`, + want: func() []*Matcher { + ms := []*Matcher{} + m, _ := NewMatcher(MatchEqual, "foo", "bar\\") + return append(ms, m) + }(), + }, + { + input: `{foo=bar\"}`, + want: func() []*Matcher { + ms := []*Matcher{} + m, _ := NewMatcher(MatchEqual, "foo", "bar\"") + return append(ms, m) + }(), + }, { input: `job=`, want: func() []*Matcher {