func TestMaps(t *testing.T) { ServerTest(t, func(t *testutil.T, server *ServerState) { if r := sendGet(t, server, "/maps?category="+string(tournament.CategoryTest)); Json(t, r).Key("data").Key("maps").Len() > 0 { t.Error("expected no maps", r) t.FailNow() } sendJSONPost(t, server, "/map/create", map[string]string{"name": "NameFoo", "source": "SourceFoo", "category": string(tournament.CategoryTest)}) if r := sendGet(t, server, "/maps?category="+string(tournament.CategoryTest)); !compareStrings(Json(t, r).Key("data").Key("maps").Array(), []string{"NameFoo"}) { t.Error("expected single player NameFoo", r) t.FailNow() } sendJSONPost(t, server, "/map/create", map[string]string{"name": "NameBar", "source": "SourceBar", "category": string(tournament.CategoryTest)}) if r := sendGet(t, server, "/maps?category="+string(tournament.CategoryTest)); !compareStringsUnordered(Json(t, r).Key("data").Key("maps").Array(), []string{"NameFoo", "NameBar"}) { t.ErrorNow("expected two maps NameFoo, NameBar", r) } }) }