@@ -0,0 +1,33 @@
|
||||
package sourcemod
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
func TestBuildPingList(t *testing.T) {
|
||||
pingID := primitive.NewObjectID()
|
||||
videoID := primitive.NewObjectID()
|
||||
ignoredID := primitive.NewObjectID()
|
||||
data := []*SourceRes{
|
||||
{ID: pingID, Type: Ping, IsActive: true, Domain: []Domain{{Url: "https://api-1.example"}, {Url: "https://api-2.example"}}},
|
||||
{ID: videoID, Type: Vid, IsActive: true, Domain: []Domain{{Url: "https://video.example"}}},
|
||||
{ID: ignoredID, Type: Customer, IsActive: true, Domain: []Domain{{Url: "https://customer.example"}}},
|
||||
}
|
||||
|
||||
got := buildPingList(data)
|
||||
if len(got.Domains) != 2 || got.Domains[0] != "https://api-1.example" || got.Domains[1] != "https://api-2.example" {
|
||||
t.Fatalf("buildPingList() domains = %#v", got.Domains)
|
||||
}
|
||||
if len(got.Sources) != 1 || got.Sources[0].ID != videoID {
|
||||
t.Fatalf("buildPingList() sources = %#v", got.Sources)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildPingListEmpty(t *testing.T) {
|
||||
got := buildPingList(nil)
|
||||
if len(got.Domains) != 0 || len(got.Sources) != 0 {
|
||||
t.Fatalf("buildPingList(nil) = %#v", got)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user