test nonzero status

This commit is contained in:
Bel LaPointe
2023-03-27 06:58:21 -06:00
parent 1842023224
commit 1f7b222b9c
2 changed files with 20 additions and 6 deletions

View File

@@ -10,6 +10,7 @@ import (
"strings"
"sync"
"testing"
"time"
"gopkg.in/yaml.v2"
)
@@ -92,8 +93,8 @@ func TestServeGM(t *testing.T) {
var result struct {
Players int `yaml:"Players"`
Users map[string]struct {
Lag string
LastActivity string
Lag string
IdleFor string `yaml:"idle_for"`
} `yaml:"Users"`
}
@@ -122,7 +123,10 @@ func TestServeGM(t *testing.T) {
{},
}
v01.cfg.Users = map[string]configUser{
"bel": configUser{},
"bel": configUser{
LastTSMS: time.Now().Add(-1*time.Minute).UnixNano() / int64(time.Millisecond),
LastLag: int64(time.Second / time.Millisecond),
},
"zach": configUser{},
"chase": configUser{},
"mason": configUser{},
@@ -144,6 +148,16 @@ func TestServeGM(t *testing.T) {
if len(result.Users) != 7 {
t.Error(result.Users)
}
if d, err := time.ParseDuration(result.Users["bel"].Lag); err != nil {
t.Error(err)
} else if d != time.Second {
t.Error(d)
}
if d, err := time.ParseDuration(result.Users["bel"].IdleFor); err != nil {
t.Error(err)
} else if d < time.Minute || d > 2*time.Minute {
t.Error(d)
}
})
})