32 lines
790 B
Go
32 lines
790 B
Go
package vidmod
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
|
|
"go.mongodb.org/mongo-driver/bson"
|
|
)
|
|
|
|
func TestLatestVIPContentFilter(t *testing.T) {
|
|
excluded := []string{"module-a", "module-b"}
|
|
got := latestVIPContentFilter(excluded)
|
|
want := bson.M{
|
|
"status": CheckPass,
|
|
"newsType": bson.M{"$in": []string{SP, SHORT}},
|
|
"coins": 0,
|
|
"freeArea": bson.M{"$ne": true},
|
|
"recoWeight": bson.M{"$ne": -1},
|
|
"mId": bson.M{"$nin": excluded},
|
|
}
|
|
if !reflect.DeepEqual(got, want) {
|
|
t.Fatalf("latestVIPContentFilter() = %#v, want %#v", got, want)
|
|
}
|
|
}
|
|
|
|
func TestLatestVIPContentFilterWithoutExcludedModules(t *testing.T) {
|
|
got := latestVIPContentFilter(nil)
|
|
if _, exists := got["mId"]; exists {
|
|
t.Fatalf("mId filter must be absent when no modules are excluded: %#v", got)
|
|
}
|
|
}
|