restore test

switch provisioner validation to cast to []interface{} first
This commit is contained in:
Alex Pilon 2019-07-31 15:35:04 -04:00
parent 732211617e
commit d1448fc319
No known key found for this signature in database
GPG Key ID: 95659F6AEFC48D7E
2 changed files with 2 additions and 3 deletions

View File

@ -293,7 +293,8 @@ func validateFn(c *terraform.ResourceConfig) (ws []string, es []error) {
// Validate service level configs // Validate service level configs
services, ok := c.Get("service") services, ok := c.Get("service")
if ok { if ok {
for _, service := range services.([]map[string]interface{}) { for _, svc := range services.([]interface{}) {
service := svc.(map[string]interface{})
strategy, ok := service["strategy"].(string) strategy, ok := service["strategy"].(string)
if ok && !updateStrategies[strategy] { if ok && !updateStrategies[strategy] {
es = append(es, errors.New(strategy+" is not a valid update strategy.")) es = append(es, errors.New(strategy+" is not a valid update strategy."))

View File

@ -47,7 +47,6 @@ func TestResourceProvisioner_Validate_bad(t *testing.T) {
} }
} }
/* FIXME panic: interface conversion: interface {} is []interface {}, not []map[string]interface {}
func TestResourceProvisioner_Validate_bad_service_config(t *testing.T) { func TestResourceProvisioner_Validate_bad_service_config(t *testing.T) {
c := testConfig(t, map[string]interface{}{ c := testConfig(t, map[string]interface{}{
"service": []interface{}{ "service": []interface{}{
@ -68,7 +67,6 @@ func TestResourceProvisioner_Validate_bad_service_config(t *testing.T) {
t.Fatalf("Should have three errors") t.Fatalf("Should have three errors")
} }
} }
*/
func testConfig(t *testing.T, c map[string]interface{}) *terraform.ResourceConfig { func testConfig(t *testing.T, c map[string]interface{}) *terraform.ResourceConfig {
return terraform.NewResourceConfigRaw(c) return terraform.NewResourceConfigRaw(c)