2023-02-07 13:31:23 +00:00
|
|
|
package shared
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2023-04-04 17:16:53 +00:00
|
|
|
"github.com/matrix-org/dendrite/syncapi/synctypes"
|
2023-02-07 13:31:23 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func Test_isStatefilterEmpty(t *testing.T) {
|
|
|
|
filterSet := []string{"a"}
|
|
|
|
boolValue := false
|
|
|
|
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
2023-04-04 17:16:53 +00:00
|
|
|
filter *synctypes.StateFilter
|
2023-02-07 13:31:23 +00:00
|
|
|
want bool
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "nil filter is empty",
|
|
|
|
filter: nil,
|
|
|
|
want: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Empty filter is empty",
|
2023-04-04 17:16:53 +00:00
|
|
|
filter: &synctypes.StateFilter{},
|
2023-02-07 13:31:23 +00:00
|
|
|
want: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "NotTypes is set",
|
2023-04-04 17:16:53 +00:00
|
|
|
filter: &synctypes.StateFilter{
|
2023-02-07 13:31:23 +00:00
|
|
|
NotTypes: &filterSet,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Types is set",
|
2023-04-04 17:16:53 +00:00
|
|
|
filter: &synctypes.StateFilter{
|
2023-02-07 13:31:23 +00:00
|
|
|
Types: &filterSet,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Senders is set",
|
2023-04-04 17:16:53 +00:00
|
|
|
filter: &synctypes.StateFilter{
|
2023-02-07 13:31:23 +00:00
|
|
|
Senders: &filterSet,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "NotSenders is set",
|
2023-04-04 17:16:53 +00:00
|
|
|
filter: &synctypes.StateFilter{
|
2023-02-07 13:31:23 +00:00
|
|
|
NotSenders: &filterSet,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "NotRooms is set",
|
2023-04-04 17:16:53 +00:00
|
|
|
filter: &synctypes.StateFilter{
|
2023-02-07 13:31:23 +00:00
|
|
|
NotRooms: &filterSet,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "ContainsURL is set",
|
2023-04-04 17:16:53 +00:00
|
|
|
filter: &synctypes.StateFilter{
|
2023-02-07 13:31:23 +00:00
|
|
|
ContainsURL: &boolValue,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
if got := isStatefilterEmpty(tt.filter); got != tt.want {
|
|
|
|
t.Errorf("isStatefilterEmpty() = %v, want %v", got, tt.want)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|