Add missing validation and tests for Spot Instance requests

pull/6265/head
DanHam 8 years ago
parent a9aa9908cd
commit 99e3487795
No known key found for this signature in database
GPG Key ID: 58E79AEDD6AA987E

@ -112,6 +112,13 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
}
}
if c.SpotPriceAutoProduct != "" {
if c.SpotPrice != "auto" {
errs = append(errs, errors.New(
"spot_price should be set to auto when spot_price_auto_product is specified"))
}
}
if c.UserData != "" && c.UserDataFile != "" {
errs = append(errs, fmt.Errorf("Only one of user_data or user_data_file can be specified."))
} else if c.UserDataFile != "" {

@ -118,13 +118,19 @@ func TestRunConfigPrepare_SpotAuto(t *testing.T) {
c := testConfig()
c.SpotPrice = "auto"
if err := c.Prepare(nil); len(err) != 1 {
t.Fatalf("err: %s", err)
t.Fatalf("spot_price_auto_product should be set when spot_price is set to auto")
}
// Good - SpotPrice and SpotPriceAutoProduct are correctly set
c.SpotPriceAutoProduct = "foo"
if err := c.Prepare(nil); len(err) != 0 {
t.Fatalf("err: %s", err)
}
c.SpotPrice = ""
if err := c.Prepare(nil); len(err) != 1 {
t.Fatalf("spot_price should be set to auto when spot_price_auto_product is set")
}
}
func TestRunConfigPrepare_SSHPort(t *testing.T) {

Loading…
Cancel
Save