feat: deduplicate ship name on transfer
This commit is contained in:
@@ -3,6 +3,7 @@ package controller_test
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
@@ -226,9 +227,6 @@ func TestShipGroupTransfer(t *testing.T) {
|
||||
assert.ErrorContains(t,
|
||||
g.ShipGroupTransfer(Race_0.Name, Race_1.Name, uuid.New()),
|
||||
e.GenericErrorText(e.ErrInputEntityNotExists))
|
||||
assert.ErrorContains(t,
|
||||
g.ShipGroupTransfer(Race_0.Name, Race_1.Name, c.ShipGroup(0).ID),
|
||||
e.GenericErrorText(e.ErrGiveawayGroupShipsTypeNotEqual))
|
||||
|
||||
orig := *c.ShipGroup(2)
|
||||
assert.NoError(t, g.ShipGroupTransfer(Race_0.Name, Race_1.Name, c.ShipGroup(2).ID)) // group #2 (3)
|
||||
@@ -275,6 +273,18 @@ func TestShipGroupTransfer(t *testing.T) {
|
||||
assert.ErrorContains(t,
|
||||
g.ShipGroupTransfer(Race_1.Name, Race_0.Name, sg.ID),
|
||||
e.GenericErrorText(e.ErrShipsBusy))
|
||||
|
||||
// transfer ship class with existing name
|
||||
originalName := c.MustShipClass(Race_0_idx, ShipType_Cruiser).Name
|
||||
assert.NoError(t, g.ShipGroupTransfer(Race_0.Name, Race_1.Name, c.ShipGroup(0).ID))
|
||||
var s *game.ShipType
|
||||
for st := range c.ListShipTypes(Race_1_idx) {
|
||||
if strings.HasPrefix(st.Name, originalName) && st.Name != originalName {
|
||||
s = st
|
||||
}
|
||||
}
|
||||
assert.NotNil(t, s)
|
||||
assert.Greater(t, len(s.Name), len(originalName))
|
||||
}
|
||||
|
||||
func TestShipGroupLoad(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user