race quit, transfer state, refactor

This commit is contained in:
Ilia Denisov
2026-02-07 01:59:11 +02:00
parent 43ba5eb07c
commit fc73cbf83a
27 changed files with 520 additions and 341 deletions
+4 -7
View File
@@ -22,8 +22,7 @@ func TestCreateShipType(t *testing.T) {
assert.ErrorContains(t, err, e.GenericErrorText(e.ErrInputUnknownRace))
err = game.CreateShipType(p, race, " "+typeName+" ", 1, 0, 0, 0, 0)
assert.NoError(t, err)
st, err := ctrl().ShipTypes(race)
assert.NoError(t, err)
st := ctrl().Cache.ShipTypes(1)
assert.Len(t, st, 1)
assert.Equal(t, st[0].Name, typeName)
assert.Equal(t, st[0].Drive.F(), 1.)
@@ -36,8 +35,7 @@ func TestCreateShipType(t *testing.T) {
assert.ErrorContains(t, err, e.GenericErrorText(e.ErrInputUnknownRace))
err = game.DeleteShipType(p, race, typeName)
assert.NoError(t, err)
st, err = ctrl().ShipTypes(race)
assert.NoError(t, err)
st = ctrl().Cache.ShipTypes(1)
assert.Len(t, st, 0)
})
}
@@ -96,7 +94,7 @@ func TestCreateShipTypeValidation(t *testing.T) {
func TestMergeShipType(t *testing.T) {
race := "race_01"
c(t, func(p func(*controller.Param), ctl func() *controller.Controller) {
c(t, func(p func(*controller.Param), ctrl func() *controller.Controller) {
err := game.CreateShipType(p, race, "Drone", 1, 0, 0, 0, 0)
assert.NoError(t, err)
err = game.CreateShipType(p, race, "Spy", 1, 0, 0, 0, 0)
@@ -109,8 +107,7 @@ func TestMergeShipType(t *testing.T) {
assert.ErrorContains(t, err, e.GenericErrorText(e.ErrInputEntityNotExists))
err = game.MergeShipType(p, race, "Spy", "Drone")
assert.NoError(t, err)
st, err := ctl().ShipTypes(race)
assert.NoError(t, err)
st := ctrl().Cache.ShipTypes(1)
assert.Len(t, st, 2)
err = game.MergeShipType(p, race, "Drone", "Cruiser")
assert.ErrorContains(t, err, e.GenericErrorText(e.ErrMergeShipTypeNotEqual))