test fillNonPlayerAliases
parent
d029d82366
commit
ceeeb8fe4b
|
|
@ -168,7 +168,11 @@ func (v01 *V01) serveGM(w http.ResponseWriter, r *http.Request) {
|
||||||
n += 1
|
n += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(b) < n {
|
if n < 1 {
|
||||||
|
w.WriteHeader(http.StatusNoContent)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if len(pool) < n {
|
||||||
http.Error(w, fmt.Sprintf("request body must contain a list of %v options", n), http.StatusBadRequest)
|
http.Error(w, fmt.Sprintf("request body must contain a list of %v options", n), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -194,6 +194,26 @@ func TestServeGM(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("fillNonPlayerAliases", func(t *testing.T) {
|
t.Run("fillNonPlayerAliases", func(t *testing.T) {
|
||||||
|
t.Run("empty", func(t *testing.T) {
|
||||||
|
v01 := NewV01(ctx, nil)
|
||||||
|
v01.cfg.Users = nil
|
||||||
|
resp := do(v01, "/gm/rpc/fillNonPlayerAliases", "[qt]")
|
||||||
|
if resp.Code != http.StatusNoContent {
|
||||||
|
t.Error(resp.Code)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("not enough", func(t *testing.T) {
|
||||||
|
v01 := NewV01(ctx, nil)
|
||||||
|
v01.cfg.Users = map[string]configUser{
|
||||||
|
"zach": configUser{Player: 0},
|
||||||
|
}
|
||||||
|
resp := do(v01, "/gm/rpc/fillNonPlayerAliases", "[]")
|
||||||
|
if resp.Code != http.StatusBadRequest {
|
||||||
|
t.Error(resp.Code)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
t.Run("happy", func(t *testing.T) {
|
t.Run("happy", func(t *testing.T) {
|
||||||
v01 := NewV01(ctx, nil)
|
v01 := NewV01(ctx, nil)
|
||||||
v01.cfg.Users = map[string]configUser{
|
v01.cfg.Users = map[string]configUser{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue