[dynamic-source-ami] add some very basic tests

This commit is contained in:
Chris Lundquist 2016-08-21 00:29:51 +00:00
parent 57e7a1a3e6
commit b4d20706ce
1 changed files with 26 additions and 0 deletions

View File

@ -28,6 +28,13 @@ func testConfig() *RunConfig {
} }
} }
func testConfigFilter() *RunConfig {
config := testConfig()
config.SourceAmi = ""
config.SourceAmiFilter = AmiFilterOptions{}
return config
}
func TestRunConfigPrepare(t *testing.T) { func TestRunConfigPrepare(t *testing.T) {
c := testConfig() c := testConfig()
err := c.Prepare(nil) err := c.Prepare(nil)
@ -52,6 +59,25 @@ func TestRunConfigPrepare_SourceAmi(t *testing.T) {
} }
} }
func TestRunConfigPrepare_SourceAmiFilterBlank(t *testing.T) {
c := testConfigFilter()
if err := c.Prepare(nil); len(err) != 1 {
t.Fatalf("err: %s", err)
}
}
func TestRunConfigPrepare_SourceAmiFilterGood(t *testing.T) {
c := testConfigFilter()
owner := "123"
filter_key := "name"
filter_value := "foo"
goodFilter := AmiFilterOptions{Owners: []*string{&owner}, Filters: map[*string]*string{&filter_key: &filter_value}}
c.SourceAmiFilter = goodFilter
if err := c.Prepare(nil); len(err) != 0 {
t.Fatalf("err: %s", err)
}
}
func TestRunConfigPrepare_SpotAuto(t *testing.T) { func TestRunConfigPrepare_SpotAuto(t *testing.T) {
c := testConfig() c := testConfig()
c.SpotPrice = "auto" c.SpotPrice = "auto"