test last GM RPC
parent
1738ce7d19
commit
ecb719a97a
|
|
@ -274,6 +274,7 @@ func (v01 *V01) serveGMVote(w http.ResponseWriter, r *http.Request) {
|
|||
v, ok := v01.cfg.Users[voter]
|
||||
if _, ok2 := v01.cfg.Users[candidate]; !ok || !ok2 {
|
||||
http.Error(w, "bad voter/candidate", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
v.Message = strings.Split(v.Message, "//")[0] + "//" + candidate
|
||||
v01.cfg.Users[voter] = v
|
||||
|
|
|
|||
|
|
@ -241,8 +241,25 @@ func TestServeGM(t *testing.T) {
|
|||
t.Run("vote", func(t *testing.T) {
|
||||
type result map[string]string
|
||||
|
||||
t.Run("cast bad vote", func(t *testing.T) {
|
||||
v01 := NewV01(ctx, nil)
|
||||
v01.cfg.Users = map[string]configUser{"bel": {}}
|
||||
resp := do(v01, "/gm/rpc/vote?user=bel&payload=?", "")
|
||||
if resp.Code != http.StatusBadRequest {
|
||||
t.Error(resp)
|
||||
}
|
||||
if v01.cfg.Users["bel"].Message != "" {
|
||||
t.Error(v01.cfg.Users["bel"].Message)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("cast vote", func(t *testing.T) {
|
||||
t.Error("not impl")
|
||||
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"].Message != "//zach" {
|
||||
t.Error(v01.cfg.Users["bel"].Message)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("get non vote", func(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue