blob: 4c1981aba1d8b24cde3895fd5831a94969aadd42 [file] [log] [blame]
package ignore
import (
data ""
func TestToQuery(t *testing.T) {
queries, err := toQuery([]Rule{})
require.NoError(t, err)
require.Len(t, queries, 0)
r1 := NewRule("", time.Now().Add(time.Hour), "config=gpu", "reason")
queries, err = toQuery([]Rule{r1})
require.NoError(t, err)
require.Equal(t, queries[0], url.Values{"config": []string{"gpu"}})
// A bad rule won't get converted
r1 = NewRule("", time.Now().Add(time.Hour), "bad=%", "reason")
queries, err = toQuery([]Rule{r1})
require.NotNil(t, err)
require.Empty(t, queries)
func TestFilterIgnored(t *testing.T) {
// With no ignore rules, nothing is filtered
ft, pm, err := FilterIgnored(data.MakeTestTile(), nil)
require.NoError(t, err)
require.Empty(t, pm)
require.Equal(t, data.MakeTestTile(), ft)
future := time.Now().Add(time.Hour)
ignores := []Rule{
NewRule("", future, "device=crosshatch", "note"),
// Now filter the tile and make sure those traces are filtered out.
ft, pm, err = FilterIgnored(data.MakeTestTile(), ignores)
require.NoError(t, err)
require.Equal(t, paramtools.ParamMatcher{
"device": {"crosshatch"},
}, pm)
require.Len(t, ft.Traces, 4)
require.NotContains(t, ft.Traces, data.CrosshatchAlphaTraceID)
require.NotContains(t, ft.Traces, data.CrosshatchBetaTraceID)