github.com/paybyphone/terraform@v0.9.5-0.20170613192930-9706042ddd51/config/config_terraform_test.go (about) 1 package config 2 3 import ( 4 "fmt" 5 "testing" 6 ) 7 8 func TestBackendHash(t *testing.T) { 9 // WARNING: The codes below should _never_ change. If they change, it 10 // means that a future TF version may falsely recognize unchanged backend 11 // configuration as changed. Ultimately this should have no adverse 12 // affect but it is annoying for users and should be avoided if possible. 13 14 cases := []struct { 15 Name string 16 Fixture string 17 Code uint64 18 }{ 19 { 20 "no backend config", 21 "backend-hash-empty", 22 0, 23 }, 24 25 { 26 "backend config with only type", 27 "backend-hash-type-only", 28 17852588448730441876, 29 }, 30 31 { 32 "backend config with type and config", 33 "backend-hash-basic", 34 10288498853650209002, 35 }, 36 } 37 38 for i, tc := range cases { 39 t.Run(fmt.Sprintf("%d-%s", i, tc.Name), func(t *testing.T) { 40 c := testConfig(t, tc.Fixture) 41 err := c.Validate() 42 if err != nil { 43 t.Fatalf("err: %s", err) 44 } 45 46 var actual uint64 47 if c.Terraform != nil && c.Terraform.Backend != nil { 48 actual = c.Terraform.Backend.Hash 49 } 50 if actual != tc.Code { 51 t.Fatalf("bad: %d != %d", actual, tc.Code) 52 } 53 }) 54 } 55 }