add case to decoder to assert to slice, then each item to a map

This commit is contained in:
Alex Pilon 2019-08-01 17:07:53 -04:00
parent d1448fc319
commit ec0402a238
No known key found for this signature in database
GPG Key ID: 95659F6AEFC48D7E
3 changed files with 10 additions and 4 deletions

View File

@ -269,7 +269,6 @@ func TestProviderValidate(t *testing.T) {
} }
} }
/* FIXME Invalid timeout structure: []interface {}{map[string]interface {}{"create":"40m"}}
func TestProviderDiff_legacyTimeoutType(t *testing.T) { func TestProviderDiff_legacyTimeoutType(t *testing.T) {
p := &Provider{ p := &Provider{
ResourcesMap: map[string]*Resource{ ResourcesMap: map[string]*Resource{
@ -307,7 +306,6 @@ func TestProviderDiff_legacyTimeoutType(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
} }
*/
func TestProviderDiff_timeoutInvalidValue(t *testing.T) { func TestProviderDiff_timeoutInvalidValue(t *testing.T) {
p := &Provider{ p := &Provider{

View File

@ -78,6 +78,16 @@ func (t *ResourceTimeout) ConfigDecode(s *Resource, c *terraform.ResourceConfig)
log.Printf("[ERROR] Invalid timeout value: %q", raw) log.Printf("[ERROR] Invalid timeout value: %q", raw)
return fmt.Errorf("Invalid Timeout value found") return fmt.Errorf("Invalid Timeout value found")
} }
case []interface{}:
for _, r := range raw {
if rMap, ok := r.(map[string]interface{}); ok {
rawTimeouts = append(rawTimeouts, rMap)
} else {
// Go will not allow a fallthrough
log.Printf("[ERROR] Invalid timeout structure: %#v", raw)
return fmt.Errorf("Invalid Timeout structure found")
}
}
default: default:
log.Printf("[ERROR] Invalid timeout structure: %#v", raw) log.Printf("[ERROR] Invalid timeout structure: %#v", raw)
return fmt.Errorf("Invalid Timeout structure found") return fmt.Errorf("Invalid Timeout structure found")

View File

@ -122,7 +122,6 @@ func TestResourceTimeout_ConfigDecode(t *testing.T) {
} }
} }
/* FIXME Expected good timeout returned:, Invalid Timeout structure found
func TestResourceTimeout_legacyConfigDecode(t *testing.T) { func TestResourceTimeout_legacyConfigDecode(t *testing.T) {
r := &Resource{ r := &Resource{
Timeouts: &ResourceTimeout{ Timeouts: &ResourceTimeout{
@ -158,7 +157,6 @@ func TestResourceTimeout_legacyConfigDecode(t *testing.T) {
t.Fatalf("bad timeout decode.\nExpected:\n%#v\nGot:\n%#v\n", expected, timeout) t.Fatalf("bad timeout decode.\nExpected:\n%#v\nGot:\n%#v\n", expected, timeout)
} }
} }
*/
func TestResourceTimeout_DiffEncode_basic(t *testing.T) { func TestResourceTimeout_DiffEncode_basic(t *testing.T) {
cases := []struct { cases := []struct {