github.com/chalford/terraform@v0.3.7-0.20150113080010-a78c69a8c81f/helper/schema/field_reader_config_test.go (about) 1 package schema 2 3 import ( 4 "testing" 5 6 "github.com/hashicorp/terraform/config" 7 "github.com/hashicorp/terraform/terraform" 8 ) 9 10 func TestConfigFieldReader_impl(t *testing.T) { 11 var _ FieldReader = new(ConfigFieldReader) 12 } 13 14 func TestConfigFieldReader(t *testing.T) { 15 testFieldReader(t, func(s map[string]*Schema) FieldReader { 16 return &ConfigFieldReader{ 17 Schema: s, 18 19 Config: testConfig(t, map[string]interface{}{ 20 "bool": true, 21 "float": 3.1415, 22 "int": 42, 23 "string": "string", 24 25 "list": []interface{}{"foo", "bar"}, 26 27 "listInt": []interface{}{21, 42}, 28 29 "map": map[string]interface{}{ 30 "foo": "bar", 31 "bar": "baz", 32 }, 33 34 "set": []interface{}{10, 50}, 35 "setDeep": []interface{}{ 36 map[string]interface{}{ 37 "index": 10, 38 "value": "foo", 39 }, 40 map[string]interface{}{ 41 "index": 50, 42 "value": "bar", 43 }, 44 }, 45 }), 46 } 47 }) 48 } 49 50 func testConfig( 51 t *testing.T, raw map[string]interface{}) *terraform.ResourceConfig { 52 rc, err := config.NewRawConfig(raw) 53 if err != nil { 54 t.Fatalf("err: %s", err) 55 } 56 57 return terraform.NewResourceConfig(rc) 58 }