Add command test for stashing
This commit is contained in:
parent
8279a08a37
commit
3bfc91b8f6
1 changed files with 25 additions and 1 deletions
|
@ -48,7 +48,31 @@ func TestCommand_Turn(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCommand_Stash(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) {
|
func TestCommand_Repair(t *testing.T) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue