feat: gamemaster

This commit is contained in:
Ilia Denisov
2026-05-03 07:59:03 +02:00
committed by GitHub
parent a7cee15115
commit 3e2622757e
229 changed files with 41521 additions and 1098 deletions
+45
View File
@@ -0,0 +1,45 @@
package router_test
import (
"net/http"
"net/http/httptest"
"testing"
"galaxy/model/rest"
"github.com/stretchr/testify/assert"
)
const apiBanishPath = "/api/v1/admin/race/banish"
func TestBanishHappyPath(t *testing.T) {
r := setupRouter()
w := httptest.NewRecorder()
req, _ := http.NewRequest(http.MethodPost, apiBanishPath, asBody(rest.BanishRequest{RaceName: "Aelinari"}))
r.ServeHTTP(w, req)
assert.Equal(t, http.StatusNoContent, w.Code, w.Body)
assert.Empty(t, w.Body.String())
}
func TestBanishValidation(t *testing.T) {
r := setupRouter()
for _, tc := range []struct {
description string
body any
}{
{"missing race_name", struct{}{}},
{"empty race_name", rest.BanishRequest{RaceName: ""}},
{"blank race_name", rest.BanishRequest{RaceName: " "}},
} {
t.Run(tc.description, func(t *testing.T) {
w := httptest.NewRecorder()
req, _ := http.NewRequest(http.MethodPost, apiBanishPath, asBody(tc.body))
r.ServeHTTP(w, req)
assert.Equal(t, http.StatusBadRequest, w.Code, w.Body)
})
}
}