simpleadmin-web 0.1.0: web panel for CS2-SimpleAdmin
This commit is contained in:
commit
4f38daf0e6
31 changed files with 6870 additions and 0 deletions
38
internal/live/live_test.go
Normal file
38
internal/live/live_test.go
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
package live
|
||||
|
||||
import "testing"
|
||||
|
||||
const sample = `wpb {"v":1,"hostname":"zio.sh | Random Skills","map":"de_mirage","maxPlayers":24,"scoreT":7,"scoreCt":9,"warmup":false}
|
||||
L 09/25/2026 - 20:00:00: something else the server logged
|
||||
wpb {"userid":2,"name":"astra","steamid":"76561198012345601","team":3,"kills":21,"deaths":9,"ping":12,"bot":false}
|
||||
wpb {"userid":5,"name":"BOT Kurt","steamid":"0","team":2,"kills":3,"deaths":10,"ping":0,"bot":true}
|
||||
wpb end
|
||||
`
|
||||
|
||||
func TestParse(t *testing.T) {
|
||||
st, err := Parse(sample)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !st.Online || st.Map != "de_mirage" || st.ScoreT != 7 || st.ScoreCT != 9 || len(st.Players) != 2 {
|
||||
t.Fatalf("unexpected %+v", st)
|
||||
}
|
||||
if h := st.Humans(); len(h) != 1 || h[0].UserID != 2 {
|
||||
t.Fatalf("humans %+v", h)
|
||||
}
|
||||
if p, ok := st.Find("76561198012345601"); !ok || p.Kills != 21 {
|
||||
t.Fatalf("find %+v %v", p, ok)
|
||||
}
|
||||
if _, ok := st.Find("0"); ok {
|
||||
t.Fatal("bots must not be found by SteamID")
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseErrors(t *testing.T) {
|
||||
if _, err := Parse("Unknown command \"css_webpanel_status\"\n"); err == nil {
|
||||
t.Fatal("missing plugin should be an error")
|
||||
}
|
||||
if _, err := Parse(`wpb {"v":1,"map":"x"}` + "\n"); err == nil {
|
||||
t.Fatal("output without end marker should be an error")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue