Add tests for Tenancy vs Spot Price

pull/10085/head
Evan Pipho 6 years ago
parent 6967e02103
commit d5d1a8708e

@ -635,6 +635,12 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
}
}
if c.Tenancy != "" && c.Tenancy != "default" {
if c.SpotPrice != "" {
errs = append(errs, fmt.Errorf("Error: Non-default tenancy cannot be used in conjunction with Spot Instances"))
}
}
return errs
}

@ -232,3 +232,23 @@ func TestRunConfigPrepare_TemporaryKeyPairName(t *testing.T) {
t.Fatal("keypair name does not match")
}
}
func TestRunConfigPrepare_TenancySpot(t *testing.T) {
c := testConfig()
c.Tenancy = "dedicated"
c.SpotPrice = "1"
if err := c.Prepare(nil); len(err) != 1 {
t.Fatal("Should error if non-default tenancy and spot price are both set")
}
}
func TestRunConfigPrepare_TenancySpotDefault(t *testing.T) {
c := testConfig()
c.Tenancy = "default"
c.SpotPrice = "1"
if err := c.Prepare(nil); len(err) != 0 {
t.Fatal("Should not error if tenancy is set to default with spot price")
}
}

Loading…
Cancel
Save