mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2026-02-11 17:50:25 +00:00
feat: add plugin Minecraft 服务器状态查询 (#1135)
This commit is contained in:
27
plugin/minecraftobserver/ping_test.go
Normal file
27
plugin/minecraftobserver/ping_test.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package minecraftobserver
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_PingListInfo(t *testing.T) {
|
||||
t.Run("normal", func(t *testing.T) {
|
||||
resp, err := getMinecraftServerStatus("cn.nekoland.top")
|
||||
if err != nil {
|
||||
t.Fatalf("getMinecraftServerStatus() error = %v", err)
|
||||
}
|
||||
msg, iconBase64 := resp.genServerSubscribeSchema("cn.nekoland.top", 123456).generateServerStatusMsg()
|
||||
fmt.Printf("msg: %v\n", msg)
|
||||
fmt.Printf("iconBase64: %v\n", iconBase64)
|
||||
})
|
||||
t.Run("不可达", func(t *testing.T) {
|
||||
ss, err := getMinecraftServerStatus("dx.123213213123123.net")
|
||||
if err == nil {
|
||||
t.Fatalf("getMinecraftServerStatus() error = %v", err)
|
||||
}
|
||||
if ss != nil {
|
||||
t.Fatalf("getMinecraftServerStatus() got = %v, want nil", ss)
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user