github.com/sfdevops1/terrra4orm@v0.11.12-beta1/helper/customdiff/testing_test.go (about) 1 package customdiff 2 3 import ( 4 "github.com/hashicorp/terraform/helper/schema" 5 "github.com/hashicorp/terraform/terraform" 6 ) 7 8 func testProvider(s map[string]*schema.Schema, cd schema.CustomizeDiffFunc) terraform.ResourceProvider { 9 return &schema.Provider{ 10 ResourcesMap: map[string]*schema.Resource{ 11 "test": { 12 Schema: s, 13 CustomizeDiff: cd, 14 }, 15 }, 16 } 17 } 18 19 func testDiff(provider terraform.ResourceProvider, old, new map[string]string) (*terraform.InstanceDiff, error) { 20 newI := make(map[string]interface{}, len(new)) 21 for k, v := range new { 22 newI[k] = v 23 } 24 25 return provider.Diff( 26 &terraform.InstanceInfo{ 27 Id: "test", 28 Type: "test", 29 ModulePath: []string{}, 30 }, 31 &terraform.InstanceState{ 32 Attributes: old, 33 }, 34 &terraform.ResourceConfig{ 35 Config: newI, 36 }, 37 ) 38 }