github.com/terraform-modules-krish/terratest@v0.29.0/modules/terraform/init_test.go (about) 1 package terraform 2 3 import ( 4 "io/ioutil" 5 "path/filepath" 6 "testing" 7 8 "github.com/terraform-modules-krish/terratest/modules/files" 9 "github.com/stretchr/testify/assert" 10 ) 11 12 func TestInitBackendConfig(t *testing.T) { 13 t.Parallel() 14 15 stateDirectory, err := ioutil.TempDir("", t.Name()) 16 if err != nil { 17 t.Fatal(err) 18 } 19 20 remoteStateFile := filepath.Join(stateDirectory, "backend.tfstate") 21 22 testFolder, err := files.CopyTerraformFolderToTemp("../../test/fixtures/terraform-backend", t.Name()) 23 if err != nil { 24 t.Fatal(err) 25 } 26 27 options := &Options{ 28 TerraformDir: testFolder, 29 BackendConfig: map[string]interface{}{ 30 "path": remoteStateFile, 31 }, 32 } 33 34 InitAndApply(t, options) 35 36 assert.FileExists(t, remoteStateFile) 37 }