Add tests for Tenancy vs Spot Price

This commit is contained in:
Evan Pipho 2020-10-11 06:06:28 +00:00
parent 6967e02103
commit d5d1a8708e
2 changed files with 26 additions and 0 deletions

View File

@ -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
}

View File

@ -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")
}
}