From a8e3ee868f670a50d00fe3d8b4f9d5284159c433 Mon Sep 17 00:00:00 2001 From: David Gageot Date: Thu, 12 Nov 2015 17:41:41 +0100 Subject: [PATCH] Simpler test code Signed-off-by: David Gageot --- commands/commands_test.go | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/commands/commands_test.go b/commands/commands_test.go index 6df17ef6db..63017b203b 100644 --- a/commands/commands_test.go +++ b/commands/commands_test.go @@ -79,39 +79,18 @@ func TestRunActionForeachMachine(t *testing.T) { runActionForeachMachine("start", machines) - expected := map[string]state.State{ - "foo": state.Running, - "bar": state.Running, - "baz": state.Running, - "spam": state.Running, - "eggs": state.Running, - "ham": state.Running, - } - for _, machine := range machines { - state, _ := machine.Driver.GetState() - if expected[machine.Name] != state { - t.Fatalf("Expected machine %s to have state %s, got state %s", machine.Name, state, expected[machine.Name]) - } - } + machineState, _ := machine.Driver.GetState() - // OK, now let's stop them all! - expected = map[string]state.State{ - "foo": state.Stopped, - "bar": state.Stopped, - "baz": state.Stopped, - "spam": state.Stopped, - "eggs": state.Stopped, - "ham": state.Stopped, + assert.Equal(t, state.Running, machineState) } runActionForeachMachine("stop", machines) for _, machine := range machines { - state, _ := machine.Driver.GetState() - if expected[machine.Name] != state { - t.Fatalf("Expected machine %s to have state %s, got state %s", machine.Name, state, expected[machine.Name]) - } + machineState, _ := machine.Driver.GetState() + + assert.Equal(t, state.Stopped, machineState) } }