Skip to content

Commit

Permalink
fix GetMinecraftInfosFrom10Names test script
Browse files Browse the repository at this point in the history
  • Loading branch information
a3510377 committed May 5, 2024
1 parent 1e5fab7 commit 06b6737
Showing 1 changed file with 23 additions and 27 deletions.
50 changes: 23 additions & 27 deletions server/utils/minecraft_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package utils

import (
"fmt"
"testing"

mapset "github.com/deckarep/golang-set/v2"
Expand Down Expand Up @@ -29,6 +28,7 @@ func TestGetMinecraftInfoFromName(t *testing.T) {
}

func TestGetMinecraftInfosFrom10Names(t *testing.T) {
// test 1.
names := []string{
"Steve", "Alex", "Noor", "Sunny", "Ari",
"Zuri", "Makena", "Kai", "Efe",
Expand All @@ -37,32 +37,28 @@ func TestGetMinecraftInfosFrom10Names(t *testing.T) {
infos, err := getMinecraftInfosFrom10Names(names)
if err != nil {
t.Error(err)
return
}
} else {
players := mapset.NewSet(
OnlineUUIDStruct{ID: "ec561538f3fd461daff5086b22154bce", Name: "Alex"},
OnlineUUIDStruct{ID: "938e960d50ab489b9b2aaf3751942989", Name: "Ari"},
OnlineUUIDStruct{ID: "20bf454f34e34010a378613546e3d0f9", Name: "efe"},
OnlineUUIDStruct{ID: "cf9858b6ed4946538e47f0e4214539f7", Name: "Kai"},
OnlineUUIDStruct{ID: "6c4bc87ce82944efa1ad63d45e2b9545", Name: "Makena"},
OnlineUUIDStruct{ID: "2d9f2227592b481d8433d13b69473ccc", Name: "noor"},
OnlineUUIDStruct{ID: "8667ba71b85a4004af54457a9734eed7", Name: "Steve"},
OnlineUUIDStruct{ID: "bafbe1cb77b348099fa3c89604bda644", Name: "Sunny"},
OnlineUUIDStruct{ID: "f5e039b93b8a45109ee8e7552e098c55", Name: "Zuri"},
)

players := mapset.NewSet(
OnlineUUIDStruct{ID: "ec561538f3fd461daff5086b22154bce", Name: "Alex"},
OnlineUUIDStruct{ID: "938e960d50ab489b9b2aaf3751942989", Name: "Ari"},
OnlineUUIDStruct{ID: "20bf454f34e34010a378613546e3d0f9", Name: "efe"},
OnlineUUIDStruct{ID: "cf9858b6ed4946538e47f0e4214539f7", Name: "Kai"},
OnlineUUIDStruct{ID: "6c4bc87ce82944efa1ad63d45e2b9545", Name: "Makena"},
OnlineUUIDStruct{ID: "2d9f2227592b481d8433d13b69473ccc", Name: "noor"},
OnlineUUIDStruct{ID: "8667ba71b85a4004af54457a9734eed7", Name: "Steve"},
OnlineUUIDStruct{ID: "bafbe1cb77b348099fa3c89604bda644", Name: "Sunny"},
OnlineUUIDStruct{ID: "f5e039b93b8a45109ee8e7552e098c55", Name: "Zuri"},
)
fmt.Println(players.Difference(mapset.NewSet(*infos...)))
if diff := players.Difference(mapset.NewSet(*infos...)); diff.Cardinality() != 0 {
t.Errorf("Expected %v, got nil", diff)
}
}

// waitMatchData := mapset.NewSet(*infos...)
// waitMatchData.Difference()
// for _, player := range players {
// if waitMatchData.Contains(player) {
// waitMatchData.Remove(player)
// } else {
// t.Errorf("Expected %v, got nil", player)
// }
// }
// if waitMatchData.Cardinality() != 0 {
// t.Errorf("Expected 0, got %d", waitMatchData.Cardinality())
// }
// test 2.
names = []string{"-test", "+test"}
infos, err = getMinecraftInfosFrom10Names(names)
if err != nil {
t.Error(err)
}
}

0 comments on commit 06b6737

Please sign in to comment.