Add unit tests for shutdown behaviour

This commit is contained in:
Patrick Robinson 2016-05-20 20:21:48 +10:00 committed by Chris Bednarski
parent 3cf2d1e356
commit b1d6d28a90
1 changed files with 35 additions and 0 deletions

View File

@ -92,3 +92,38 @@ func TestBuilderPrepare_InvalidKey(t *testing.T) {
t.Fatal("should have error") t.Fatal("should have error")
} }
} }
func TestBuilderPrepare_InvalidShutdownBehaviour(t *testing.T) {
var b Builder
config := testConfig()
// Test good
config["shutdown_behaviour"] = "terminate"
warnings, err := b.Prepare(config)
if len(warnings) > 0 {
t.Fatalf("bad: %#v", warnings)
}
if err != nil {
t.Fatalf("should not have error: %s", err)
}
// Test good
config["shutdown_behaviour"] = "stop"
warnings, err = b.Prepare(config)
if len(warnings) > 0 {
t.Fatalf("bad: %#v", warnings)
}
if err != nil {
t.Fatalf("should not have error: %s", err)
}
// Test bad
config["shutdown_behaviour"] = "foobar"
warnings, err = b.Prepare(config)
if len(warnings) > 0 {
t.Fatalf("bad: %#v", warnings)
}
if err == nil {
t.Fatal("should have error")
}
}