|
|
|
|
@ -3,6 +3,7 @@ package schema
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"reflect"
|
|
|
|
|
"strings"
|
|
|
|
|
"testing"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
@ -277,6 +278,54 @@ func TestProviderValidate(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestProviderDiff_timeoutInvalidType(t *testing.T) {
|
|
|
|
|
p := &Provider{
|
|
|
|
|
ResourcesMap: map[string]*Resource{
|
|
|
|
|
"blah": &Resource{
|
|
|
|
|
Schema: map[string]*Schema{
|
|
|
|
|
"foo": {
|
|
|
|
|
Type: TypeInt,
|
|
|
|
|
Optional: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
Timeouts: &ResourceTimeout{
|
|
|
|
|
Create: DefaultTimeout(10 * time.Minute),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
invalidCfg := map[string]interface{}{
|
|
|
|
|
"foo": 42,
|
|
|
|
|
"timeouts": []map[string]interface{}{
|
|
|
|
|
map[string]interface{}{
|
|
|
|
|
"create": "40m",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
ic, err := config.NewRawConfig(invalidCfg)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_, err = p.Diff(
|
|
|
|
|
&terraform.InstanceInfo{
|
|
|
|
|
Type: "blah",
|
|
|
|
|
},
|
|
|
|
|
nil,
|
|
|
|
|
terraform.NewResourceConfig(ic),
|
|
|
|
|
)
|
|
|
|
|
if err == nil {
|
|
|
|
|
t.Fatal("Expected provider.Diff to fail with invalid timeout type")
|
|
|
|
|
}
|
|
|
|
|
expectedErrMsg := "Invalid Timeout structure"
|
|
|
|
|
if !strings.Contains(err.Error(), expectedErrMsg) {
|
|
|
|
|
t.Fatalf("Unexpected error message: %q\nExpected message to contain %q",
|
|
|
|
|
err.Error(),
|
|
|
|
|
expectedErrMsg)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestProviderValidateResource(t *testing.T) {
|
|
|
|
|
cases := []struct {
|
|
|
|
|
P *Provider
|
|
|
|
|
|