Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Commit ec0402a

Browse files
committed
add case to decoder to assert to slice, then each item to a map
1 parent d1448fc commit ec0402a

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

helper/schema/provider_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ func TestProviderValidate(t *testing.T) {
269269
}
270270
}
271271

272-
/* FIXME Invalid timeout structure: []interface {}{map[string]interface {}{"create":"40m"}}
273272
func TestProviderDiff_legacyTimeoutType(t *testing.T) {
274273
p := &Provider{
275274
ResourcesMap: map[string]*Resource{
@@ -307,7 +306,6 @@ func TestProviderDiff_legacyTimeoutType(t *testing.T) {
307306
t.Fatal(err)
308307
}
309308
}
310-
*/
311309

312310
func TestProviderDiff_timeoutInvalidValue(t *testing.T) {
313311
p := &Provider{

helper/schema/resource_timeout.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,16 @@ func (t *ResourceTimeout) ConfigDecode(s *Resource, c *terraform.ResourceConfig)
7878
log.Printf("[ERROR] Invalid timeout value: %q", raw)
7979
return fmt.Errorf("Invalid Timeout value found")
8080
}
81+
case []interface{}:
82+
for _, r := range raw {
83+
if rMap, ok := r.(map[string]interface{}); ok {
84+
rawTimeouts = append(rawTimeouts, rMap)
85+
} else {
86+
// Go will not allow a fallthrough
87+
log.Printf("[ERROR] Invalid timeout structure: %#v", raw)
88+
return fmt.Errorf("Invalid Timeout structure found")
89+
}
90+
}
8191
default:
8292
log.Printf("[ERROR] Invalid timeout structure: %#v", raw)
8393
return fmt.Errorf("Invalid Timeout structure found")

helper/schema/resource_timeout_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ func TestResourceTimeout_ConfigDecode(t *testing.T) {
122122
}
123123
}
124124

125-
/* FIXME Expected good timeout returned:, Invalid Timeout structure found
126125
func TestResourceTimeout_legacyConfigDecode(t *testing.T) {
127126
r := &Resource{
128127
Timeouts: &ResourceTimeout{
@@ -158,7 +157,6 @@ func TestResourceTimeout_legacyConfigDecode(t *testing.T) {
158157
t.Fatalf("bad timeout decode.\nExpected:\n%#v\nGot:\n%#v\n", expected, timeout)
159158
}
160159
}
161-
*/
162160

163161
func TestResourceTimeout_DiffEncode_basic(t *testing.T) {
164162
cases := []struct {

0 commit comments

Comments
 (0)