rename State.GM THINGS to State.GM.Things

This commit is contained in:
Bel LaPointe
2023-03-27 11:00:40 -06:00
parent f647a03467
commit 9ece270a13
3 changed files with 36 additions and 29 deletions

View File

@@ -178,7 +178,9 @@ func TestServeGM(t *testing.T) {
v01.cfg.Quiet = false
v01.cfg.Users = map[string]configUser{
"bel": configUser{State: configUserState{
Alias: "driver",
GM: configUserStateGM{
Alias: "driver",
},
Message: "if someone else says 'driver', then you get to play",
}},
"broadcast": configUser{State: configUserState{
@@ -189,10 +191,10 @@ func TestServeGM(t *testing.T) {
if !v01.cfg.Quiet {
t.Error(v01.cfg.Quiet)
}
if v := v01.cfg.Users["bel"]; v.State.Alias != "" {
t.Error(v.State.Alias)
} else if v.State.Message != "driver" {
t.Error(v.State.Message)
if v := v01.cfg.Users["bel"]; v.State.GM.Alias != "" {
t.Error(v.State.GM.Alias)
} else if v.State.GM.LastAlias != "driver" {
t.Error(v.State.GM.LastAlias)
}
if bc := v01.cfg.Users["broadcast"]; bc.State.Message == ":)" {
t.Error(bc)
@@ -227,13 +229,13 @@ func TestServeGM(t *testing.T) {
"zach": configUser{State: configUserState{Player: 0}},
}
do(v01, "/gm/rpc/fillNonPlayerAliases", "[qt]")
if v := v01.cfg.Users["bel"]; v.State.Alias != "" {
t.Error(v.State.Alias)
if v := v01.cfg.Users["bel"]; v.State.GM.Alias != "" {
t.Error(v.State.GM.Alias)
} else if v.State.Player != 1 {
t.Error(v.State.Player)
}
if v := v01.cfg.Users["zach"]; v.State.Alias != "qt" {
t.Error(v.State.Alias)
if v := v01.cfg.Users["zach"]; v.State.GM.Alias != "qt" {
t.Error(v.State.GM.Alias)
} else if v.State.Player != 0 {
t.Error(v.State.Player)
}
@@ -259,8 +261,8 @@ func TestServeGM(t *testing.T) {
v01 := NewV01(ctx, nil)
v01.cfg.Users = map[string]configUser{"bel": {}, "zach": {}}
do(v01, "/gm/rpc/vote?user=bel&payload=zach", "")
if v01.cfg.Users["bel"].State.Vote != "zach" {
t.Error(v01.cfg.Users["bel"].State.Vote)
if v01.cfg.Users["bel"].State.GM.Vote != "zach" {
t.Error(v01.cfg.Users["bel"].State.GM.Vote)
}
})
@@ -283,7 +285,7 @@ func TestServeGM(t *testing.T) {
t.Run("get mid vote", func(t *testing.T) {
v01 := NewV01(ctx, nil)
v01.cfg.Users = map[string]configUser{"bel": {State: configUserState{Vote: "zach", Message: "driver"}}}
v01.cfg.Users = map[string]configUser{"bel": {State: configUserState{GM: configUserStateGM{Vote: "zach"}, Message: "driver"}}}
resp := do(v01, "/gm/rpc/vote", "", "GET")
var result result
if err := yaml.Unmarshal(resp.Body.Bytes(), &result); err != nil {
@@ -319,9 +321,9 @@ func TestServeGM(t *testing.T) {
t.Run("happy", func(t *testing.T) {
v01 := NewV01(ctx, nil)
v01.cfg.Users = map[string]configUser{
"bel": configUser{State: configUserState{Vote: "zach", Message: "driver", Player: 1}},
"zach": configUser{State: configUserState{Vote: "bel", Message: "pizza"}},
"bill": configUser{State: configUserState{Vote: "bel", Message: "", Player: 2}},
"bel": configUser{State: configUserState{GM: configUserStateGM{Vote: "zach", LastAlias: "driver"}, Player: 1}},
"zach": configUser{State: configUserState{GM: configUserStateGM{Vote: "bel", LastAlias: "pizza"}}},
"bill": configUser{State: configUserState{GM: configUserStateGM{Vote: "bel"}, Player: 2}},
}
resp := do(v01, "/gm/rpc/elect?alias=pizza", "")
var result result
@@ -349,9 +351,9 @@ func TestServeGM(t *testing.T) {
v01 := NewV01(ctx, nil)
v01.cfg.Players = []configPlayer{{}}
v01.cfg.Users = map[string]configUser{
"bel": configUser{State: configUserState{Vote: "zach", Message: "driver", Player: 1}},
"zach": configUser{State: configUserState{Vote: "bel", Message: ""}},
"bill": configUser{State: configUserState{Vote: "bel", Message: ""}},
"bel": configUser{State: configUserState{GM: configUserStateGM{Vote: "zach", LastAlias: "driver"}, Player: 1}},
"zach": configUser{State: configUserState{GM: configUserStateGM{Vote: "bel"}}},
"bill": configUser{State: configUserState{GM: configUserStateGM{Vote: "bel"}}},
}
resp := do(v01, "/gm/rpc/elect?alias=driver", "")
var result result
@@ -385,8 +387,8 @@ func TestServeGM(t *testing.T) {
v01 := NewV01(ctx, nil)
v01.cfg.Players = []configPlayer{{}}
v01.cfg.Users = map[string]configUser{
"bel": configUser{State: configUserState{Vote: "zach", Message: "driver", Player: 1}},
"zach": configUser{State: configUserState{Vote: "bel", Message: "pizza"}},
"bel": configUser{State: configUserState{GM: configUserStateGM{Vote: "zach", LastAlias: "driver"}, Player: 1}},
"zach": configUser{State: configUserState{GM: configUserStateGM{Vote: "bel", LastAlias: "pizza"}}},
}
resp := do(v01, "/gm/rpc/elect?alias=pizza", "")
var result result