lib/promrelabel: add tests for verifying that regex works as expected in single quotes and double quotes

This commit is contained in:
Aliaksandr Valialkin 2021-07-27 10:50:39 +03:00
parent 3c22b5c41e
commit 92628f9f07

View File

@ -859,6 +859,44 @@ func TestApplyRelabelConfigs(t *testing.T) {
Value: "yyy",
},
})
// regex in single quotes
f(`
- action: labeldrop
regex: 'dropme'
`, []prompbmarshal.Label{
{
Name: "xxx",
Value: "yyy",
},
{
Name: "dropme",
Value: "aaa",
},
}, false, []prompbmarshal.Label{
{
Name: "xxx",
Value: "yyy",
},
})
// regex in double quotes
f(`
- action: labeldrop
regex: "dropme"
`, []prompbmarshal.Label{
{
Name: "xxx",
Value: "yyy",
},
{
Name: "dropme",
Value: "aaa",
},
}, false, []prompbmarshal.Label{
{
Name: "xxx",
Value: "yyy",
},
})
})
t.Run("labeldrop-prefix", func(t *testing.T) {
f(`