diff --git a/pkg/rove/command_test.go b/pkg/rove/command_test.go index f55c6cb..0dc2f11 100644 --- a/pkg/rove/command_test.go +++ b/pkg/rove/command_test.go @@ -48,7 +48,31 @@ func TestCommand_Turn(t *testing.T) { } func TestCommand_Stash(t *testing.T) { - // TODO: Test the stash command + w := NewWorld(8) + name, err := w.SpawnRover() + assert.NoError(t, err) + + info, err := w.GetRover(name) + assert.NoError(t, err) + assert.Empty(t, info.Inventory) + + // Drop a pickup below us + w.Atlas.SetObject(info.Pos, Object{Type: roveapi.Object_RockSmall}) + + // Try and stash it + err = w.Enqueue(name, &roveapi.Command{Command: roveapi.CommandType_stash}) + assert.NoError(t, err) + w.Tick() + + // Check we now have it in the inventory + info, err = w.GetRover(name) + assert.NoError(t, err) + assert.Equal(t, 1, len(info.Inventory)) + assert.Equal(t, Object{Type: roveapi.Object_RockSmall}, info.Inventory[0]) + + // Check it's no longer on the atlas + _, obj := w.Atlas.QueryPosition(info.Pos) + assert.Equal(t, Object{Type: roveapi.Object_ObjectUnknown}, obj) } func TestCommand_Repair(t *testing.T) {