diff --git a/filter.go b/filter.go index 92fb38f..337bddb 100644 --- a/filter.go +++ b/filter.go @@ -12,9 +12,11 @@ type Filter struct { Authors StringList Since *time.Time Until *time.Time - Tags map[string]StringList + Tags TagMap } +type TagMap map[string]StringList + func (eff Filters) Match(event *Event) bool { for _, filter := range eff { if filter.Matches(event) { diff --git a/filter_aux.go b/filter_aux.go index 1bf29b1..f4a4ce9 100644 --- a/filter_aux.go +++ b/filter_aux.go @@ -20,7 +20,7 @@ func (f *Filter) UnmarshalJSON(payload []byte) error { return fmt.Errorf("filter is not an object") } - f.Tags = make(map[string]StringList) + f.Tags = make(TagMap) var visiterr error obj.Visit(func(k []byte, v *fastjson.Value) { diff --git a/filter_test.go b/filter_test.go index 7a6c212..0aed216 100644 --- a/filter_test.go +++ b/filter_test.go @@ -26,7 +26,7 @@ func TestFilterMarshal(t *testing.T) { filterj, err := json.Marshal(Filter{ Kinds: IntList{1, 2, 4}, - Tags: map[string]StringList{"fruit": {"banana", "mango"}}, + Tags: TagMap{"fruit": {"banana", "mango"}}, Until: &tm, }) if err != nil { @@ -50,7 +50,7 @@ func TestFilterMatching(t *testing.T) { if !(Filter{ Kinds: IntList{4, 5}, - Tags: map[string]StringList{ + Tags: TagMap{ "p": {"ooo"}, }, IDs: StringList{"prefix"}, @@ -72,8 +72,8 @@ func TestFilterEquality(t *testing.T) { } if !FilterEqual( - Filter{Kinds: IntList{4, 5}, Tags: map[string]StringList{"letter": {"a", "b"}}}, - Filter{Kinds: IntList{4, 5}, Tags: map[string]StringList{"letter": {"b", "a"}}}, + Filter{Kinds: IntList{4, 5}, Tags: TagMap{"letter": {"a", "b"}}}, + Filter{Kinds: IntList{4, 5}, Tags: TagMap{"letter": {"b", "a"}}}, ) { t.Error("kind+tags filters should be equal") } @@ -82,13 +82,13 @@ func TestFilterEquality(t *testing.T) { if !FilterEqual( Filter{ Kinds: IntList{4, 5}, - Tags: map[string]StringList{"letter": {"a", "b"}, "fruit": {"banana"}}, + Tags: TagMap{"letter": {"a", "b"}, "fruit": {"banana"}}, Since: &tm, IDs: StringList{"aaaa", "bbbb"}, }, Filter{ Kinds: IntList{5, 4}, - Tags: map[string]StringList{"letter": {"a", "b"}, "fruit": {"banana"}}, + Tags: TagMap{"letter": {"a", "b"}, "fruit": {"banana"}}, Since: &tm, IDs: StringList{"aaaa", "bbbb"}, },