helper/schema: name test cases w/ strings

I promised myself that next time I jumped in this file I'd fix this up.
Now we don't have to manually index the file with comments, we can just
add descriptive names to the test cases!
This commit is contained in:
Paul Hinze 2015-11-20 13:41:34 -06:00
parent 24d15820c1
commit 938281024f
1 changed files with 92 additions and 214 deletions

View File

@ -124,7 +124,7 @@ func TestValueType_Zero(t *testing.T) {
} }
func TestSchemaMap_Diff(t *testing.T) { func TestSchemaMap_Diff(t *testing.T) {
cases := []struct { cases := map[string]struct {
Schema map[string]*Schema Schema map[string]*Schema
State *terraform.InstanceState State *terraform.InstanceState
Config map[string]interface{} Config map[string]interface{}
@ -132,12 +132,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Diff *terraform.InstanceDiff Diff *terraform.InstanceDiff
Err bool Err bool
}{ }{
/* "#0": {
* String decode
*/
// #0
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"availability_zone": &Schema{ "availability_zone": &Schema{
Type: TypeString, Type: TypeString,
@ -166,8 +161,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #1 "#1": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"availability_zone": &Schema{ "availability_zone": &Schema{
Type: TypeString, Type: TypeString,
@ -194,8 +188,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #2 "#2": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"availability_zone": &Schema{ "availability_zone": &Schema{
Type: TypeString, Type: TypeString,
@ -216,8 +209,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #3 Computed, but set in config "#3 Computed, but set in config": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"availability_zone": &Schema{ "availability_zone": &Schema{
Type: TypeString, Type: TypeString,
@ -248,8 +240,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #4 Default "#4 Default": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"availability_zone": &Schema{ "availability_zone": &Schema{
Type: TypeString, Type: TypeString,
@ -274,8 +265,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #5 DefaultFunc, value "#5 DefaultFunc, value": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"availability_zone": &Schema{ "availability_zone": &Schema{
Type: TypeString, Type: TypeString,
@ -302,8 +292,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #6 DefaultFunc, configuration set "#6 DefaultFunc, configuration set": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"availability_zone": &Schema{ "availability_zone": &Schema{
Type: TypeString, Type: TypeString,
@ -332,8 +321,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #7 String with StateFunc "#7 String with StateFunc": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"availability_zone": &Schema{ "availability_zone": &Schema{
Type: TypeString, Type: TypeString,
@ -364,8 +352,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #8 Variable (just checking) "#8 Variable (just checking)": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"availability_zone": &Schema{ "availability_zone": &Schema{
Type: TypeString, Type: TypeString,
@ -395,8 +382,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #9 Variable computed "#9 Variable computed": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"availability_zone": &Schema{ "availability_zone": &Schema{
Type: TypeString, Type: TypeString,
@ -426,12 +412,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
/* "#10 Int decode": {
* Int decode
*/
// #10
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"port": &Schema{ "port": &Schema{
Type: TypeInt, Type: TypeInt,
@ -460,12 +441,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
/* "#11 bool decode": {
* Bool decode
*/
// #11
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"port": &Schema{ "port": &Schema{
Type: TypeBool, Type: TypeBool,
@ -494,12 +470,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
/* "#12 Bool": {
* Bool
*/
// #12
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"delete": &Schema{ "delete": &Schema{
Type: TypeBool, Type: TypeBool,
@ -521,12 +492,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
/* "#13 List decode": {
* List decode
*/
// #13
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"ports": &Schema{ "ports": &Schema{
Type: TypeList, Type: TypeList,
@ -565,8 +531,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #14 "#14": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"ports": &Schema{ "ports": &Schema{
Type: TypeList, Type: TypeList,
@ -609,8 +574,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #15 "#15": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"ports": &Schema{ "ports": &Schema{
Type: TypeList, Type: TypeList,
@ -643,8 +607,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #16 "#16": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"ports": &Schema{ "ports": &Schema{
Type: TypeList, Type: TypeList,
@ -671,8 +634,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #17 "#17": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"ports": &Schema{ "ports": &Schema{
Type: TypeList, Type: TypeList,
@ -709,8 +671,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #18 "#18": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"ports": &Schema{ "ports": &Schema{
Type: TypeList, Type: TypeList,
@ -754,8 +715,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #19 "#19": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"ports": &Schema{ "ports": &Schema{
Type: TypeList, Type: TypeList,
@ -781,12 +741,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
/* "#20 Set": {
* Set
*/
// #20
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"ports": &Schema{ "ports": &Schema{
Type: TypeSet, Type: TypeSet,
@ -828,8 +783,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #21 "#21 Set": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"ports": &Schema{ "ports": &Schema{
Type: TypeSet, Type: TypeSet,
@ -855,8 +809,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #22 "#22 Set": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"ports": &Schema{ "ports": &Schema{
Type: TypeSet, Type: TypeSet,
@ -885,8 +838,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #23 "#23 Set": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"ports": &Schema{ "ports": &Schema{
Type: TypeSet, Type: TypeSet,
@ -932,8 +884,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #24 "#24 Set": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"ports": &Schema{ "ports": &Schema{
Type: TypeSet, Type: TypeSet,
@ -969,8 +920,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #25 "#25 Set": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"ports": &Schema{ "ports": &Schema{
Type: TypeSet, Type: TypeSet,
@ -1018,8 +968,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #26 "#26 Set": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"ports": &Schema{ "ports": &Schema{
Type: TypeSet, Type: TypeSet,
@ -1063,8 +1012,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #27 "#27 Set": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"ports": &Schema{ "ports": &Schema{
Type: TypeSet, Type: TypeSet,
@ -1092,8 +1040,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #28 "#28 Set": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"ingress": &Schema{ "ingress": &Schema{
Type: TypeSet, Type: TypeSet,
@ -1145,12 +1092,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
/* "#29 List of structure decode": {
* List of structure decode
*/
// #29
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"ingress": &Schema{ "ingress": &Schema{
Type: TypeList, Type: TypeList,
@ -1192,12 +1134,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
/* "#30 ComputedWhen": {
* ComputedWhen
*/
// #30
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"availability_zone": &Schema{ "availability_zone": &Schema{
Type: TypeString, Type: TypeString,
@ -1227,8 +1164,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #31 "#31": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"availability_zone": &Schema{ "availability_zone": &Schema{
Type: TypeString, Type: TypeString,
@ -1306,12 +1242,7 @@ func TestSchemaMap_Diff(t *testing.T) {
}, },
*/ */
/* "#32 Maps": {
* Maps
*/
// #32
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"config_vars": &Schema{ "config_vars": &Schema{
Type: TypeMap, Type: TypeMap,
@ -1345,8 +1276,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #33 "#33 Maps": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"config_vars": &Schema{ "config_vars": &Schema{
Type: TypeMap, Type: TypeMap,
@ -1383,8 +1313,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #34 "#34 Maps": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"vars": &Schema{ "vars": &Schema{
Type: TypeMap, Type: TypeMap,
@ -1424,8 +1353,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #35 "#35 Maps": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"vars": &Schema{ "vars": &Schema{
Type: TypeMap, Type: TypeMap,
@ -1446,8 +1374,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #36 "#36 Maps": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"config_vars": &Schema{ "config_vars": &Schema{
Type: TypeList, Type: TypeList,
@ -1486,8 +1413,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #37 "#37 Maps": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"config_vars": &Schema{ "config_vars": &Schema{
Type: TypeList, Type: TypeList,
@ -1529,12 +1455,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
/* "#38 ForceNews": {
* ForceNews
*/
// #38
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"availability_zone": &Schema{ "availability_zone": &Schema{
Type: TypeString, Type: TypeString,
@ -1579,8 +1500,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #39 Set "#39 Set": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"availability_zone": &Schema{ "availability_zone": &Schema{
Type: TypeString, Type: TypeString,
@ -1630,8 +1550,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #40 Set "#40 Set": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"instances": &Schema{ "instances": &Schema{
Type: TypeSet, Type: TypeSet,
@ -1669,8 +1588,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #41 Set "#41 Set": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"route": &Schema{ "route": &Schema{
Type: TypeSet, Type: TypeSet,
@ -1730,8 +1648,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #42 Set "#42 Set": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"route": &Schema{ "route": &Schema{
Type: TypeSet, Type: TypeSet,
@ -1796,8 +1713,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #43 - Computed maps "#43 - Computed maps": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"vars": &Schema{ "vars": &Schema{
Type: TypeMap, Type: TypeMap,
@ -1821,8 +1737,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #44 - Computed maps "#44 - Computed maps": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"vars": &Schema{ "vars": &Schema{
Type: TypeMap, Type: TypeMap,
@ -1858,8 +1773,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #45 - Empty "#45 - Empty": {
{
Schema: map[string]*Schema{}, Schema: map[string]*Schema{},
State: &terraform.InstanceState{}, State: &terraform.InstanceState{},
@ -1871,8 +1785,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #46 - Float "#46 - Float": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"some_threshold": &Schema{ "some_threshold": &Schema{
Type: TypeFloat, Type: TypeFloat,
@ -1901,8 +1814,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #47 - https://github.com/hashicorp/terraform/issues/824 "#47 - https://github.com/hashicorp/terraform/issues/824": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"block_device": &Schema{ "block_device": &Schema{
Type: TypeSet, Type: TypeSet,
@ -1955,8 +1867,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #48 - Zero value in state shouldn't result in diff "#48 - Zero value in state shouldn't result in diff": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"port": &Schema{ "port": &Schema{
Type: TypeBool, Type: TypeBool,
@ -1978,8 +1889,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #49 Set - Same as #48 but for sets "#49 Set - Same as #48 but for sets": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"route": &Schema{ "route": &Schema{
Type: TypeSet, Type: TypeSet,
@ -2021,8 +1931,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #50 - A set computed element shouldn't cause a diff "#50 - A set computed element shouldn't cause a diff": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"active": &Schema{ "active": &Schema{
Type: TypeBool, Type: TypeBool,
@ -2044,8 +1953,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #51 - An empty set should show up in the diff "#51 - An empty set should show up in the diff": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"instances": &Schema{ "instances": &Schema{
Type: TypeSet, Type: TypeSet,
@ -2085,8 +1993,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #52 - Map with empty value "#52 - Map with empty value": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"vars": &Schema{ "vars": &Schema{
Type: TypeMap, Type: TypeMap,
@ -2117,8 +2024,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #53 - Unset bool, not in state "#53 - Unset bool, not in state": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"force": &Schema{ "force": &Schema{
Type: TypeBool, Type: TypeBool,
@ -2136,8 +2042,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #54 - Unset set, not in state "#54 - Unset set, not in state": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"metadata_keys": &Schema{ "metadata_keys": &Schema{
Type: TypeSet, Type: TypeSet,
@ -2157,8 +2062,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #55 - Unset list in state, should not show up computed "#55 - Unset list in state, should not show up computed": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"metadata_keys": &Schema{ "metadata_keys": &Schema{
Type: TypeList, Type: TypeList,
@ -2182,8 +2086,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #56 - Set element computed substring "#56 - Set element computed substring": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"ports": &Schema{ "ports": &Schema{
Type: TypeSet, Type: TypeSet,
@ -2218,9 +2121,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #57 - Computed map without config that's known to be empty does not "#57 Computed map without config that's known to be empty does not generate diff": {
// generate diff
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"tags": &Schema{ "tags": &Schema{
Type: TypeMap, Type: TypeMap,
@ -2241,8 +2142,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #58 Set with hyphen keys "#58 Set with hyphen keys": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"route": &Schema{ "route": &Schema{
Type: TypeSet, Type: TypeSet,
@ -2298,8 +2198,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #59: StateFunc in nested set (#1759) "#59: StateFunc in nested set (#1759)": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"service_account": &Schema{ "service_account": &Schema{
Type: TypeList, Type: TypeList,
@ -2364,8 +2263,7 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false, Err: false,
}, },
// #60 - Removing set elements "#60 - Removing set elements": {
{
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"instances": &Schema{ "instances": &Schema{
Type: TypeSet, Type: TypeSet,
@ -2418,10 +2316,10 @@ func TestSchemaMap_Diff(t *testing.T) {
}, },
} }
for i, tc := range cases { for tn, tc := range cases {
c, err := config.NewRawConfig(tc.Config) c, err := config.NewRawConfig(tc.Config)
if err != nil { if err != nil {
t.Fatalf("#%d err: %s", i, err) t.Fatalf("#%q err: %s", tn, err)
} }
if len(tc.ConfigVariables) > 0 { if len(tc.ConfigVariables) > 0 {
@ -2431,18 +2329,18 @@ func TestSchemaMap_Diff(t *testing.T) {
} }
if err := c.Interpolate(vars); err != nil { if err := c.Interpolate(vars); err != nil {
t.Fatalf("#%d err: %s", i, err) t.Fatalf("#%q err: %s", tn, err)
} }
} }
d, err := schemaMap(tc.Schema).Diff( d, err := schemaMap(tc.Schema).Diff(
tc.State, terraform.NewResourceConfig(c)) tc.State, terraform.NewResourceConfig(c))
if err != nil != tc.Err { if err != nil != tc.Err {
t.Fatalf("#%d err: %s", i, err) t.Fatalf("#%q err: %s", tn, err)
} }
if !reflect.DeepEqual(tc.Diff, d) { if !reflect.DeepEqual(tc.Diff, d) {
t.Fatalf("#%d:\n\nexpected: %#v\n\ngot:\n\n%#v", i, tc.Diff, d) t.Fatalf("#%q:\n\nexpected: %#v\n\ngot:\n\n%#v", tn, tc.Diff, d)
} }
} }
} }
@ -2640,17 +2538,16 @@ func TestSchemaMap_InputDefault(t *testing.T) {
} }
func TestSchemaMap_InternalValidate(t *testing.T) { func TestSchemaMap_InternalValidate(t *testing.T) {
cases := []struct { cases := map[string]struct {
In map[string]*Schema In map[string]*Schema
Err bool Err bool
}{ }{
{ "nothing": {
nil, nil,
false, false,
}, },
// No optional and no required "Both optional and required": {
{
map[string]*Schema{ map[string]*Schema{
"foo": &Schema{ "foo": &Schema{
Type: TypeInt, Type: TypeInt,
@ -2661,8 +2558,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) {
true, true,
}, },
// No optional and no required "No optional and no required": {
{
map[string]*Schema{ map[string]*Schema{
"foo": &Schema{ "foo": &Schema{
Type: TypeInt, Type: TypeInt,
@ -2671,8 +2567,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) {
true, true,
}, },
// Missing Type "Missing Type": {
{
map[string]*Schema{ map[string]*Schema{
"foo": &Schema{ "foo": &Schema{
Required: true, Required: true,
@ -2681,8 +2576,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) {
true, true,
}, },
// Required but computed "Required but computed": {
{
map[string]*Schema{ map[string]*Schema{
"foo": &Schema{ "foo": &Schema{
Type: TypeInt, Type: TypeInt,
@ -2693,8 +2587,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) {
true, true,
}, },
// Looks good "Looks good": {
{
map[string]*Schema{ map[string]*Schema{
"foo": &Schema{ "foo": &Schema{
Type: TypeString, Type: TypeString,
@ -2704,8 +2597,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) {
false, false,
}, },
// Computed but has default "Computed but has default": {
{
map[string]*Schema{ map[string]*Schema{
"foo": &Schema{ "foo": &Schema{
Type: TypeInt, Type: TypeInt,
@ -2717,8 +2609,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) {
true, true,
}, },
// Required but has default "Required but has default": {
{
map[string]*Schema{ map[string]*Schema{
"foo": &Schema{ "foo": &Schema{
Type: TypeInt, Type: TypeInt,
@ -2730,8 +2621,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) {
true, true,
}, },
// List element not set "List element not set": {
{
map[string]*Schema{ map[string]*Schema{
"foo": &Schema{ "foo": &Schema{
Type: TypeList, Type: TypeList,
@ -2740,8 +2630,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) {
true, true,
}, },
// List default "List default": {
{
map[string]*Schema{ map[string]*Schema{
"foo": &Schema{ "foo": &Schema{
Type: TypeList, Type: TypeList,
@ -2752,8 +2641,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) {
true, true,
}, },
// List element computed "List element computed": {
{
map[string]*Schema{ map[string]*Schema{
"foo": &Schema{ "foo": &Schema{
Type: TypeList, Type: TypeList,
@ -2767,8 +2655,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) {
true, true,
}, },
// List element with Set set "List element with Set set": {
{
map[string]*Schema{ map[string]*Schema{
"foo": &Schema{ "foo": &Schema{
Type: TypeList, Type: TypeList,
@ -2780,8 +2667,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) {
true, true,
}, },
// Set element with no Set set "Set element with no Set set": {
{
map[string]*Schema{ map[string]*Schema{
"foo": &Schema{ "foo": &Schema{
Type: TypeSet, Type: TypeSet,
@ -2792,8 +2678,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) {
false, false,
}, },
// Required but computed "Required but computedWhen": {
{
map[string]*Schema{ map[string]*Schema{
"foo": &Schema{ "foo": &Schema{
Type: TypeInt, Type: TypeInt,
@ -2804,8 +2689,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) {
true, true,
}, },
// Conflicting attributes cannot be required "Conflicting attributes cannot be required": {
{
map[string]*Schema{ map[string]*Schema{
"blacklist": &Schema{ "blacklist": &Schema{
Type: TypeBool, Type: TypeBool,
@ -2820,8 +2704,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) {
true, true,
}, },
// Attribute with conflicts cannot be required "Attribute with conflicts cannot be required": {
{
map[string]*Schema{ map[string]*Schema{
"whitelist": &Schema{ "whitelist": &Schema{
Type: TypeBool, Type: TypeBool,
@ -2832,8 +2715,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) {
true, true,
}, },
// ConflictsWith cannot be used w/ Computed "ConflictsWith cannot be used w/ Computed": {
{
map[string]*Schema{ map[string]*Schema{
"blacklist": &Schema{ "blacklist": &Schema{
Type: TypeBool, Type: TypeBool,
@ -2848,8 +2730,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) {
true, true,
}, },
// ConflictsWith cannot be used w/ ComputedWhen "ConflictsWith cannot be used w/ ComputedWhen": {
{
map[string]*Schema{ map[string]*Schema{
"blacklist": &Schema{ "blacklist": &Schema{
Type: TypeBool, Type: TypeBool,
@ -2864,8 +2745,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) {
true, true,
}, },
// Sub-resource invalid "Sub-resource invalid": {
{
map[string]*Schema{ map[string]*Schema{
"foo": &Schema{ "foo": &Schema{
Type: TypeList, Type: TypeList,
@ -2880,8 +2760,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) {
true, true,
}, },
// Sub-resource valid "Sub-resource valid": {
{
map[string]*Schema{ map[string]*Schema{
"foo": &Schema{ "foo": &Schema{
Type: TypeList, Type: TypeList,
@ -2899,8 +2778,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) {
false, false,
}, },
// ValidateFunc on non-primitive "ValidateFunc on non-primitive": {
{
map[string]*Schema{ map[string]*Schema{
"foo": &Schema{ "foo": &Schema{
Type: TypeSet, Type: TypeSet,
@ -2914,13 +2792,13 @@ func TestSchemaMap_InternalValidate(t *testing.T) {
}, },
} }
for i, tc := range cases { for tn, tc := range cases {
err := schemaMap(tc.In).InternalValidate(schemaMap{}) err := schemaMap(tc.In).InternalValidate(schemaMap{})
if err != nil != tc.Err { if err != nil != tc.Err {
if tc.Err { if tc.Err {
t.Fatalf("%d: Expected error did not occur:\n\n%#v", i, tc.In) t.Fatalf("%q: Expected error did not occur:\n\n%#v", tn, tc.In)
} }
t.Fatalf("%d: Unexpected error occurred:\n\n%#v", i, tc.In) t.Fatalf("%q: Unexpected error occurred:\n\n%#v", tn, tc.In)
} }
} }