Best Ginkgo code snippet using integration_test.RemoveFile
integration_test.go
Source:integration_test.go
1package test2import (3 "bytes"4 "fmt"5 "io"6 "io/ioutil"7 "math/rand"8 "os"9 "path/filepath"10 "strings"11 "testing"12 "time"13 "github.com/aws/aws-sdk-go/aws"14 "github.com/aws/aws-sdk-go/service/dynamodb"15 "github.com/aws/aws-sdk-go/service/s3"16 "github.com/gruntwork-io/terragrunt/aws_helper"17 "github.com/gruntwork-io/terragrunt/cli"18 "github.com/gruntwork-io/terragrunt/config"19 terragruntDynamoDb "github.com/gruntwork-io/terragrunt/dynamodb"20 "github.com/gruntwork-io/terragrunt/errors"21 "github.com/gruntwork-io/terragrunt/options"22 "github.com/gruntwork-io/terragrunt/remote"23 "github.com/gruntwork-io/terragrunt/util"24 "github.com/stretchr/testify/assert"25)26// hard-code this to match the test fixture for now27const (28 TERRAFORM_REMOTE_STATE_S3_REGION = "us-west-2"29 TEST_FIXTURE_PATH = "fixture/"30 TEST_FIXTURE_INCLUDE_PATH = "fixture-include/"31 TEST_FIXTURE_INCLUDE_CHILD_REL_PATH = "qa/my-app"32 TEST_FIXTURE_STACK = "fixture-stack/"33 TEST_FIXTURE_OUTPUT_ALL = "fixture-output-all"34 TEST_FIXTURE_STDOUT = "fixture-download/stdout-test"35 TEST_FIXTURE_EXTRA_ARGS_PATH = "fixture-extra-args/"36 TEST_FIXTURE_LOCAL_DOWNLOAD_PATH = "fixture-download/local"37 TEST_FIXTURE_REMOTE_DOWNLOAD_PATH = "fixture-download/remote"38 TEST_FIXTURE_OVERRIDE_DOWNLOAD_PATH = "fixture-download/override"39 TEST_FIXTURE_LOCAL_RELATIVE_DOWNLOAD_PATH = "fixture-download/local-relative"40 TEST_FIXTURE_REMOTE_RELATIVE_DOWNLOAD_PATH = "fixture-download/remote-relative"41 TEST_FIXTURE_LOCAL_WITH_BACKEND = "fixture-download/local-with-backend"42 TEST_FIXTURE_REMOTE_WITH_BACKEND = "fixture-download/remote-with-backend"43 TEST_FIXTURE_LOCAL_MISSING_BACKEND = "fixture-download/local-with-missing-backend"44 TEST_FIXTURE_LOCAL_WITH_HIDDEN_FOLDER = "fixture-download/local-with-hidden-folder"45 TEST_FIXTURE_OLD_CONFIG_INCLUDE_PATH = "fixture-old-terragrunt-config/include"46 TEST_FIXTURE_OLD_CONFIG_INCLUDE_CHILD_UPDATED_PATH = "fixture-old-terragrunt-config/include-child-updated"47 TEST_FIXTURE_OLD_CONFIG_INCLUDE_PARENT_UPDATED_PATH = "fixture-old-terragrunt-config/include-parent-updated"48 TEST_FIXTURE_OLD_CONFIG_STACK_PATH = "fixture-old-terragrunt-config/stack"49 TEST_FIXTURE_OLD_CONFIG_DOWNLOAD_PATH = "fixture-old-terragrunt-config/download"50 TEST_FIXTURE_FAILED_TERRAFORM = "fixture-failure"51 TERRAFORM_FOLDER = ".terraform"52 TERRAFORM_STATE = "terraform.tfstate"53 TERRAFORM_STATE_BACKUP = "terraform.tfstate.backup"54)55func init() {56 rand.Seed(time.Now().UnixNano())57}58func TestTerragruntWorksWithLocalTerraformVersion(t *testing.T) {59 t.Parallel()60 cleanupTerraformFolder(t, TEST_FIXTURE_PATH)61 s3BucketName := fmt.Sprintf("terragrunt-test-bucket-%s", strings.ToLower(uniqueId()))62 lockTableName := fmt.Sprintf("terragrunt-test-locks-%s", strings.ToLower(uniqueId()))63 defer deleteS3Bucket(t, TERRAFORM_REMOTE_STATE_S3_REGION, s3BucketName)64 defer cleanupTableForTest(t, lockTableName, TERRAFORM_REMOTE_STATE_S3_REGION)65 tmpTerragruntConfigPath := createTmpTerragruntConfig(t, TEST_FIXTURE_PATH, s3BucketName, lockTableName, config.DefaultTerragruntConfigPath)66 runTerragrunt(t, fmt.Sprintf("terragrunt apply --terragrunt-non-interactive --terragrunt-config %s --terragrunt-working-dir %s", tmpTerragruntConfigPath, TEST_FIXTURE_PATH))67 validateS3BucketExists(t, TERRAFORM_REMOTE_STATE_S3_REGION, s3BucketName)68}69func TestTerragruntWorksWithIncludes(t *testing.T) {70 t.Parallel()71 childPath := util.JoinPath(TEST_FIXTURE_INCLUDE_PATH, TEST_FIXTURE_INCLUDE_CHILD_REL_PATH)72 cleanupTerraformFolder(t, childPath)73 s3BucketName := fmt.Sprintf("terragrunt-test-bucket-%s", strings.ToLower(uniqueId()))74 defer deleteS3Bucket(t, TERRAFORM_REMOTE_STATE_S3_REGION, s3BucketName)75 tmpTerragruntConfigPath := createTmpTerragruntConfigWithParentAndChild(t, TEST_FIXTURE_INCLUDE_PATH, TEST_FIXTURE_INCLUDE_CHILD_REL_PATH, s3BucketName, config.DefaultTerragruntConfigPath, config.DefaultTerragruntConfigPath)76 runTerragrunt(t, fmt.Sprintf("terragrunt apply --terragrunt-non-interactive --terragrunt-config %s --terragrunt-working-dir %s", tmpTerragruntConfigPath, childPath))77}78func TestTerragruntWorksWithIncludesAndOldConfig(t *testing.T) {79 t.Parallel()80 childPath := util.JoinPath(TEST_FIXTURE_OLD_CONFIG_INCLUDE_PATH, "child")81 cleanupTerraformFolder(t, childPath)82 s3BucketName := fmt.Sprintf("terragrunt-test-bucket-%s", strings.ToLower(uniqueId()))83 defer deleteS3Bucket(t, TERRAFORM_REMOTE_STATE_S3_REGION, s3BucketName)84 tmpTerragruntConfigPath := createTmpTerragruntConfigWithParentAndChild(t, TEST_FIXTURE_OLD_CONFIG_INCLUDE_PATH, "child", s3BucketName, config.OldTerragruntConfigPath, config.OldTerragruntConfigPath)85 runTerragrunt(t, fmt.Sprintf("terragrunt apply --terragrunt-non-interactive --terragrunt-config %s --terragrunt-working-dir %s", tmpTerragruntConfigPath, childPath))86}87func TestTerragruntWorksWithIncludesChildUpdatedAndOldConfig(t *testing.T) {88 t.Parallel()89 childPath := util.JoinPath(TEST_FIXTURE_OLD_CONFIG_INCLUDE_CHILD_UPDATED_PATH, "child")90 cleanupTerraformFolder(t, childPath)91 s3BucketName := fmt.Sprintf("terragrunt-test-bucket-%s", strings.ToLower(uniqueId()))92 defer deleteS3Bucket(t, TERRAFORM_REMOTE_STATE_S3_REGION, s3BucketName)93 tmpTerragruntConfigPath := createTmpTerragruntConfigWithParentAndChild(t, TEST_FIXTURE_OLD_CONFIG_INCLUDE_CHILD_UPDATED_PATH, "child", s3BucketName, config.OldTerragruntConfigPath, config.DefaultTerragruntConfigPath)94 runTerragrunt(t, fmt.Sprintf("terragrunt apply --terragrunt-non-interactive --terragrunt-config %s --terragrunt-working-dir %s", tmpTerragruntConfigPath, childPath))95}96func TestTerragruntWorksWithIncludesParentUpdatedAndOldConfig(t *testing.T) {97 t.Parallel()98 childPath := util.JoinPath(TEST_FIXTURE_OLD_CONFIG_INCLUDE_PARENT_UPDATED_PATH, "child")99 cleanupTerraformFolder(t, childPath)100 s3BucketName := fmt.Sprintf("terragrunt-test-bucket-%s", strings.ToLower(uniqueId()))101 defer deleteS3Bucket(t, TERRAFORM_REMOTE_STATE_S3_REGION, s3BucketName)102 tmpTerragruntConfigPath := createTmpTerragruntConfigWithParentAndChild(t, TEST_FIXTURE_OLD_CONFIG_INCLUDE_PARENT_UPDATED_PATH, "child", s3BucketName, config.DefaultTerragruntConfigPath, config.OldTerragruntConfigPath)103 runTerragrunt(t, fmt.Sprintf("terragrunt apply --terragrunt-non-interactive --terragrunt-config %s --terragrunt-working-dir %s", tmpTerragruntConfigPath, childPath))104}105func TestTerragruntReportsTerraformErrorsWithPlanAll(t *testing.T) {106 cleanupTerraformFolder(t, TEST_FIXTURE_FAILED_TERRAFORM)107 tmpEnvPath := copyEnvironment(t, TEST_FIXTURE_FAILED_TERRAFORM)108 rootTerragruntConfigPath := util.JoinPath(tmpEnvPath, "fixture-failure")109 cmd := fmt.Sprintf("terragrunt plan-all --terragrunt-non-interactive --terragrunt-working-dir %s", rootTerragruntConfigPath)110 var (111 stdout bytes.Buffer112 stderr bytes.Buffer113 )114 // Call runTerragruntCommand directly because this command contains failures (which causes runTerragruntRedirectOutput to abort) but we don't care.115 if err := runTerragruntCommand(t, cmd, &stdout, &stderr); err == nil {116 t.Fatalf("Failed to properly fail command: %v. The terraform should be bad", cmd)117 }118 output := stdout.String()119 errOutput := stderr.String()120 fmt.Printf("STDERR is %s.\n STDOUT is %s", errOutput, output)121 assert.True(t, strings.Contains(errOutput, "missingvar1") || strings.Contains(output, "missingvar1"))122 assert.True(t, strings.Contains(errOutput, "missingvar2") || strings.Contains(output, "missingvar2"))123}124func TestTerragruntOutputAllCommand(t *testing.T) {125 t.Parallel()126 s3BucketName := fmt.Sprintf("terragrunt-test-bucket-%s", strings.ToLower(uniqueId()))127 defer deleteS3Bucket(t, TERRAFORM_REMOTE_STATE_S3_REGION, s3BucketName)128 tmpEnvPath := copyEnvironment(t, TEST_FIXTURE_OUTPUT_ALL)129 rootTerragruntConfigPath := util.JoinPath(tmpEnvPath, TEST_FIXTURE_OUTPUT_ALL, config.DefaultTerragruntConfigPath)130 copyTerragruntConfigAndFillPlaceholders(t, rootTerragruntConfigPath, rootTerragruntConfigPath, s3BucketName, "not-used")131 environmentPath := fmt.Sprintf("%s/%s/env1", tmpEnvPath, TEST_FIXTURE_OUTPUT_ALL)132 runTerragrunt(t, fmt.Sprintf("terragrunt apply-all --terragrunt-non-interactive --terragrunt-working-dir %s -var terraform_remote_state_s3_bucket=\"%s\"", environmentPath, s3BucketName))133 var (134 stdout bytes.Buffer135 stderr bytes.Buffer136 )137 runTerragruntRedirectOutput(t, fmt.Sprintf("terragrunt output-all --terragrunt-non-interactive --terragrunt-working-dir %s", environmentPath), &stdout, &stderr)138 output := stdout.String()139 assert.True(t, strings.Contains(output, "app1 output"))140 assert.True(t, strings.Contains(output, "app2 output"))141 assert.True(t, strings.Contains(output, "app3 output"))142 assert.True(t, (strings.Index(output, "app3 output") < strings.Index(output, "app1 output")) && (strings.Index(output, "app1 output") < strings.Index(output, "app2 output")))143}144func TestTerragruntValidateAllCommand(t *testing.T) {145 t.Parallel()146 s3BucketName := fmt.Sprintf("terragrunt-test-bucket-%s", strings.ToLower(uniqueId()))147 defer deleteS3Bucket(t, TERRAFORM_REMOTE_STATE_S3_REGION, s3BucketName)148 tmpEnvPath := copyEnvironment(t, TEST_FIXTURE_OUTPUT_ALL)149 rootTerragruntConfigPath := util.JoinPath(tmpEnvPath, TEST_FIXTURE_OUTPUT_ALL, config.DefaultTerragruntConfigPath)150 copyTerragruntConfigAndFillPlaceholders(t, rootTerragruntConfigPath, rootTerragruntConfigPath, s3BucketName, "not-used")151 environmentPath := fmt.Sprintf("%s/%s/env1", tmpEnvPath, TEST_FIXTURE_OUTPUT_ALL)152 runTerragrunt(t, fmt.Sprintf("terragrunt validate-all --terragrunt-non-interactive --terragrunt-working-dir %s -var terraform_remote_state_s3_bucket=\"%s\"", environmentPath, s3BucketName))153}154// Check that Terragrunt does not pollute stdout with anything155func TestTerragruntStdOut(t *testing.T) {156 t.Parallel()157 var (158 stdout bytes.Buffer159 stderr bytes.Buffer160 )161 runTerragrunt(t, fmt.Sprintf("terragrunt apply --terragrunt-non-interactive --terragrunt-working-dir %s", TEST_FIXTURE_STDOUT))162 runTerragruntRedirectOutput(t, fmt.Sprintf("terragrunt output foo --terragrunt-non-interactive --terragrunt-working-dir %s", TEST_FIXTURE_STDOUT), &stdout, &stderr)163 output := stdout.String()164 assert.Equal(t, "foo\n", output)165}166func TestTerragruntOutputAllCommandSpecificVariableIgnoreDependencyErrors(t *testing.T) {167 t.Parallel()168 s3BucketName := fmt.Sprintf("terragrunt-test-bucket-%s", strings.ToLower(uniqueId()))169 defer deleteS3Bucket(t, TERRAFORM_REMOTE_STATE_S3_REGION, s3BucketName)170 tmpEnvPath := copyEnvironment(t, TEST_FIXTURE_OUTPUT_ALL)171 rootTerragruntConfigPath := util.JoinPath(tmpEnvPath, TEST_FIXTURE_OUTPUT_ALL, config.DefaultTerragruntConfigPath)172 copyTerragruntConfigAndFillPlaceholders(t, rootTerragruntConfigPath, rootTerragruntConfigPath, s3BucketName, "not-used")173 environmentPath := fmt.Sprintf("%s/%s/env1", tmpEnvPath, TEST_FIXTURE_OUTPUT_ALL)174 runTerragrunt(t, fmt.Sprintf("terragrunt apply-all --terragrunt-non-interactive --terragrunt-working-dir %s -var terraform_remote_state_s3_bucket=\"%s\"", environmentPath, s3BucketName))175 var (176 stdout bytes.Buffer177 stderr bytes.Buffer178 )179 // Call runTerragruntCommand directly because this command contains failures (which causes runTerragruntRedirectOutput to abort) but we don't care.180 runTerragruntCommand(t, fmt.Sprintf("terragrunt output-all app2_text --terragrunt-ignore-dependency-errors --terragrunt-non-interactive --terragrunt-working-dir %s", environmentPath), &stdout, &stderr)181 output := stdout.String()182 // Without --terragrunt-ignore-dependency-errors, app2 never runs because its dependencies have "errors" since they don't have the output "app2_text".183 assert.True(t, strings.Contains(output, "app2 output"))184}185func TestTerragruntStackCommands(t *testing.T) {186 t.Parallel()187 s3BucketName := fmt.Sprintf("terragrunt-test-bucket-%s", strings.ToLower(uniqueId()))188 lockTableName := fmt.Sprintf("terragrunt-test-locks-%s", strings.ToLower(uniqueId()))189 defer deleteS3Bucket(t, TERRAFORM_REMOTE_STATE_S3_REGION, s3BucketName)190 defer cleanupTableForTest(t, lockTableName, TERRAFORM_REMOTE_STATE_S3_REGION)191 tmpEnvPath := copyEnvironment(t, TEST_FIXTURE_STACK)192 rootTerragruntConfigPath := util.JoinPath(tmpEnvPath, "fixture-stack", config.DefaultTerragruntConfigPath)193 copyTerragruntConfigAndFillPlaceholders(t, rootTerragruntConfigPath, rootTerragruntConfigPath, s3BucketName, lockTableName)194 mgmtEnvironmentPath := fmt.Sprintf("%s/fixture-stack/mgmt", tmpEnvPath)195 stageEnvironmentPath := fmt.Sprintf("%s/fixture-stack/stage", tmpEnvPath)196 runTerragrunt(t, fmt.Sprintf("terragrunt apply-all --terragrunt-non-interactive --terragrunt-working-dir %s -var terraform_remote_state_s3_bucket=\"%s\"", mgmtEnvironmentPath, s3BucketName))197 runTerragrunt(t, fmt.Sprintf("terragrunt apply-all --terragrunt-non-interactive --terragrunt-working-dir %s -var terraform_remote_state_s3_bucket=\"%s\"", stageEnvironmentPath, s3BucketName))198 runTerragrunt(t, fmt.Sprintf("terragrunt output-all --terragrunt-non-interactive --terragrunt-working-dir %s", mgmtEnvironmentPath))199 runTerragrunt(t, fmt.Sprintf("terragrunt output-all --terragrunt-non-interactive --terragrunt-working-dir %s", stageEnvironmentPath))200 runTerragrunt(t, fmt.Sprintf("terragrunt destroy-all --terragrunt-non-interactive --terragrunt-working-dir %s -var terraform_remote_state_s3_bucket=\"%s\"", stageEnvironmentPath, s3BucketName))201 runTerragrunt(t, fmt.Sprintf("terragrunt destroy-all --terragrunt-non-interactive --terragrunt-working-dir %s -var terraform_remote_state_s3_bucket=\"%s\"", mgmtEnvironmentPath, s3BucketName))202}203func TestTerragruntStackCommandsWithOldConfig(t *testing.T) {204 t.Parallel()205 s3BucketName := fmt.Sprintf("terragrunt-test-bucket-%s", strings.ToLower(uniqueId()))206 defer deleteS3Bucket(t, TERRAFORM_REMOTE_STATE_S3_REGION, s3BucketName)207 tmpEnvPath := copyEnvironment(t, TEST_FIXTURE_OLD_CONFIG_STACK_PATH)208 rootPath := util.JoinPath(tmpEnvPath, "fixture-old-terragrunt-config/stack")209 stagePath := util.JoinPath(rootPath, "stage")210 rootTerragruntConfigPath := util.JoinPath(rootPath, config.OldTerragruntConfigPath)211 copyTerragruntConfigAndFillPlaceholders(t, rootTerragruntConfigPath, rootTerragruntConfigPath, s3BucketName, "not-used")212 runTerragrunt(t, fmt.Sprintf("terragrunt apply-all --terragrunt-non-interactive --terragrunt-working-dir %s -var terraform_remote_state_s3_bucket=\"%s\"", stagePath, s3BucketName))213 runTerragrunt(t, fmt.Sprintf("terragrunt output-all --terragrunt-non-interactive --terragrunt-working-dir %s", stagePath))214 runTerragrunt(t, fmt.Sprintf("terragrunt destroy-all --terragrunt-non-interactive --terragrunt-working-dir %s -var terraform_remote_state_s3_bucket=\"%s\"", stagePath, s3BucketName))215}216func TestLocalDownload(t *testing.T) {217 t.Parallel()218 cleanupTerraformFolder(t, TEST_FIXTURE_LOCAL_DOWNLOAD_PATH)219 runTerragrunt(t, fmt.Sprintf("terragrunt apply --terragrunt-non-interactive --terragrunt-working-dir %s", TEST_FIXTURE_LOCAL_DOWNLOAD_PATH))220 // Run a second time to make sure the temporary folder can be reused without errors221 runTerragrunt(t, fmt.Sprintf("terragrunt apply --terragrunt-non-interactive --terragrunt-working-dir %s", TEST_FIXTURE_LOCAL_DOWNLOAD_PATH))222}223func TestLocalDownloadWithHiddenFolder(t *testing.T) {224 t.Parallel()225 cleanupTerraformFolder(t, TEST_FIXTURE_LOCAL_WITH_HIDDEN_FOLDER)226 runTerragrunt(t, fmt.Sprintf("terragrunt apply --terragrunt-non-interactive --terragrunt-working-dir %s", TEST_FIXTURE_LOCAL_WITH_HIDDEN_FOLDER))227 // Run a second time to make sure the temporary folder can be reused without errors228 runTerragrunt(t, fmt.Sprintf("terragrunt apply --terragrunt-non-interactive --terragrunt-working-dir %s", TEST_FIXTURE_LOCAL_WITH_HIDDEN_FOLDER))229}230func TestLocalDownloadWithOldConfig(t *testing.T) {231 t.Parallel()232 cleanupTerraformFolder(t, TEST_FIXTURE_OLD_CONFIG_DOWNLOAD_PATH)233 runTerragrunt(t, fmt.Sprintf("terragrunt apply --terragrunt-non-interactive --terragrunt-working-dir %s", TEST_FIXTURE_OLD_CONFIG_DOWNLOAD_PATH))234 // Run a second time to make sure the temporary folder can be reused without errors235 runTerragrunt(t, fmt.Sprintf("terragrunt apply --terragrunt-non-interactive --terragrunt-working-dir %s", TEST_FIXTURE_OLD_CONFIG_DOWNLOAD_PATH))236}237func TestLocalDownloadWithRelativePath(t *testing.T) {238 t.Parallel()239 cleanupTerraformFolder(t, TEST_FIXTURE_LOCAL_RELATIVE_DOWNLOAD_PATH)240 runTerragrunt(t, fmt.Sprintf("terragrunt apply --terragrunt-non-interactive --terragrunt-working-dir %s", TEST_FIXTURE_LOCAL_RELATIVE_DOWNLOAD_PATH))241 // Run a second time to make sure the temporary folder can be reused without errors242 runTerragrunt(t, fmt.Sprintf("terragrunt apply --terragrunt-non-interactive --terragrunt-working-dir %s", TEST_FIXTURE_LOCAL_RELATIVE_DOWNLOAD_PATH))243}244func TestRemoteDownload(t *testing.T) {245 t.Parallel()246 cleanupTerraformFolder(t, TEST_FIXTURE_REMOTE_DOWNLOAD_PATH)247 runTerragrunt(t, fmt.Sprintf("terragrunt apply --terragrunt-non-interactive --terragrunt-working-dir %s", TEST_FIXTURE_REMOTE_DOWNLOAD_PATH))248 // Run a second time to make sure the temporary folder can be reused without errors249 runTerragrunt(t, fmt.Sprintf("terragrunt apply --terragrunt-non-interactive --terragrunt-working-dir %s", TEST_FIXTURE_REMOTE_DOWNLOAD_PATH))250}251func TestRemoteDownloadWithRelativePath(t *testing.T) {252 t.Parallel()253 cleanupTerraformFolder(t, TEST_FIXTURE_REMOTE_RELATIVE_DOWNLOAD_PATH)254 runTerragrunt(t, fmt.Sprintf("terragrunt apply --terragrunt-non-interactive --terragrunt-working-dir %s", TEST_FIXTURE_REMOTE_RELATIVE_DOWNLOAD_PATH))255 // Run a second time to make sure the temporary folder can be reused without errors256 runTerragrunt(t, fmt.Sprintf("terragrunt apply --terragrunt-non-interactive --terragrunt-working-dir %s", TEST_FIXTURE_REMOTE_RELATIVE_DOWNLOAD_PATH))257}258func TestRemoteDownloadOverride(t *testing.T) {259 t.Parallel()260 cleanupTerraformFolder(t, TEST_FIXTURE_OVERRIDE_DOWNLOAD_PATH)261 runTerragrunt(t, fmt.Sprintf("terragrunt apply --terragrunt-non-interactive --terragrunt-working-dir %s --terragrunt-source %s", TEST_FIXTURE_OVERRIDE_DOWNLOAD_PATH, "../hello-world"))262 // Run a second time to make sure the temporary folder can be reused without errors263 runTerragrunt(t, fmt.Sprintf("terragrunt apply --terragrunt-non-interactive --terragrunt-working-dir %s --terragrunt-source %s", TEST_FIXTURE_OVERRIDE_DOWNLOAD_PATH, "../hello-world"))264}265func TestLocalWithBackend(t *testing.T) {266 t.Parallel()267 s3BucketName := fmt.Sprintf("terragrunt-test-bucket-%s", strings.ToLower(uniqueId()))268 lockTableName := fmt.Sprintf("terragrunt-lock-table-%s", strings.ToLower(uniqueId()))269 defer deleteS3Bucket(t, TERRAFORM_REMOTE_STATE_S3_REGION, s3BucketName)270 defer cleanupTableForTest(t, lockTableName, TERRAFORM_REMOTE_STATE_S3_REGION)271 tmpEnvPath := copyEnvironment(t, "fixture-download")272 rootPath := util.JoinPath(tmpEnvPath, TEST_FIXTURE_LOCAL_WITH_BACKEND)273 rootTerragruntConfigPath := util.JoinPath(rootPath, config.DefaultTerragruntConfigPath)274 copyTerragruntConfigAndFillPlaceholders(t, rootTerragruntConfigPath, rootTerragruntConfigPath, s3BucketName, lockTableName)275 runTerragrunt(t, fmt.Sprintf("terragrunt apply --terragrunt-non-interactive --terragrunt-working-dir %s", rootPath))276 // Run a second time to make sure the temporary folder can be reused without errors277 runTerragrunt(t, fmt.Sprintf("terragrunt apply --terragrunt-non-interactive --terragrunt-working-dir %s", rootPath))278}279func TestLocalWithMissingBackend(t *testing.T) {280 t.Parallel()281 s3BucketName := fmt.Sprintf("terragrunt-test-bucket-%s", strings.ToLower(uniqueId()))282 lockTableName := fmt.Sprintf("terragrunt-lock-table-%s", strings.ToLower(uniqueId()))283 defer deleteS3Bucket(t, TERRAFORM_REMOTE_STATE_S3_REGION, s3BucketName)284 defer cleanupTableForTest(t, lockTableName, TERRAFORM_REMOTE_STATE_S3_REGION)285 tmpEnvPath := copyEnvironment(t, "fixture-download")286 rootPath := util.JoinPath(tmpEnvPath, TEST_FIXTURE_LOCAL_MISSING_BACKEND)287 rootTerragruntConfigPath := util.JoinPath(rootPath, config.DefaultTerragruntConfigPath)288 copyTerragruntConfigAndFillPlaceholders(t, rootTerragruntConfigPath, rootTerragruntConfigPath, s3BucketName, lockTableName)289 err := runTerragruntCommand(t, fmt.Sprintf("terragrunt apply --terragrunt-non-interactive --terragrunt-working-dir %s", rootPath), os.Stdout, os.Stderr)290 if assert.Error(t, err) {291 underlying := errors.Unwrap(err)292 assert.IsType(t, cli.BackendNotDefined{}, underlying)293 }294}295func TestRemoteWithBackend(t *testing.T) {296 t.Parallel()297 s3BucketName := fmt.Sprintf("terragrunt-test-bucket-%s", strings.ToLower(uniqueId()))298 lockTableName := fmt.Sprintf("terragrunt-lock-table-%s", strings.ToLower(uniqueId()))299 defer deleteS3Bucket(t, TERRAFORM_REMOTE_STATE_S3_REGION, s3BucketName)300 defer cleanupTableForTest(t, lockTableName, TERRAFORM_REMOTE_STATE_S3_REGION)301 tmpEnvPath := copyEnvironment(t, TEST_FIXTURE_REMOTE_WITH_BACKEND)302 rootPath := util.JoinPath(tmpEnvPath, TEST_FIXTURE_REMOTE_WITH_BACKEND)303 rootTerragruntConfigPath := util.JoinPath(rootPath, config.DefaultTerragruntConfigPath)304 copyTerragruntConfigAndFillPlaceholders(t, rootTerragruntConfigPath, rootTerragruntConfigPath, s3BucketName, lockTableName)305 runTerragrunt(t, fmt.Sprintf("terragrunt apply --terragrunt-non-interactive --terragrunt-working-dir %s", rootPath))306 // Run a second time to make sure the temporary folder can be reused without errors307 runTerragrunt(t, fmt.Sprintf("terragrunt apply --terragrunt-non-interactive --terragrunt-working-dir %s", rootPath))308}309func TestExtraArguments(t *testing.T) {310 // Do not use t.Parallel() on this test, it will infers with the other TestExtraArguments.* tests311 out := new(bytes.Buffer)312 runTerragruntRedirectOutput(t, fmt.Sprintf("terragrunt apply --terragrunt-non-interactive --terragrunt-working-dir %s", TEST_FIXTURE_EXTRA_ARGS_PATH), out, os.Stderr)313 t.Log(out.String())314 assert.Contains(t, out.String(), "Hello, World from dev!")315}316func TestExtraArgumentsWithEnv(t *testing.T) {317 // Do not use t.Parallel() on this test, it will infers with the other TestExtraArguments.* tests318 out := new(bytes.Buffer)319 os.Setenv("TF_VAR_env", "prod")320 defer os.Unsetenv("TF_VAR_env")321 runTerragruntRedirectOutput(t, fmt.Sprintf("terragrunt apply --terragrunt-non-interactive --terragrunt-working-dir %s", TEST_FIXTURE_EXTRA_ARGS_PATH), out, os.Stderr)322 t.Log(out.String())323 assert.Contains(t, out.String(), "Hello, World!")324}325func TestExtraArgumentsWithRegion(t *testing.T) {326 // Do not use t.Parallel() on this test, it will infers with the other TestExtraArguments.* tests327 out := new(bytes.Buffer)328 os.Setenv("TF_VAR_region", "us-west-2")329 defer os.Unsetenv("TF_VAR_region")330 runTerragruntRedirectOutput(t, fmt.Sprintf("terragrunt apply --terragrunt-non-interactive --terragrunt-working-dir %s", TEST_FIXTURE_EXTRA_ARGS_PATH), out, os.Stderr)331 t.Log(out.String())332 assert.Contains(t, out.String(), "Hello, World from Oregon!")333}334func TestPriorityOrderOfArgument(t *testing.T) {335 // Do not use t.Parallel() on this test, it will infers with the other TestExtraArguments.* tests336 out := new(bytes.Buffer)337 injectedValue := "Injected-directly-by-argument"338 runTerragruntRedirectOutput(t, fmt.Sprintf("terragrunt apply -var extra_var=%s --terragrunt-non-interactive --terragrunt-working-dir %s", injectedValue, TEST_FIXTURE_EXTRA_ARGS_PATH), out, os.Stderr)339 t.Log(out.String())340 // And the result value for test should be the injected variable since the injected arguments are injected before the suplied parameters,341 // so our override of extra_var should be the last argument.342 assert.Contains(t, out.String(), fmt.Sprintf("test = %s", injectedValue))343}344// This tests terragrunt properly passes through terraform commands and any number of specified args345func TestTerraformCommandCliArgs(t *testing.T) {346 t.Parallel()347 testCases := []struct {348 command []string349 expected string350 }{351 {352 []string{"version"},353 "terraform version",354 },355 {356 []string{"version", "foo"},357 "terraform version foo",358 },359 {360 []string{"version", "foo", "bar", "baz"},361 "terraform version foo bar baz",362 },363 {364 []string{"version", "foo", "bar", "baz", "foobar"},365 "terraform version foo bar baz foobar",366 },367 }368 for _, testCase := range testCases {369 cmd := fmt.Sprintf("terragrunt %s --terragrunt-non-interactive --terragrunt-working-dir %s", strings.Join(testCase.command, " "), TEST_FIXTURE_EXTRA_ARGS_PATH)370 var (371 stdout bytes.Buffer372 stderr bytes.Buffer373 )374 runTerragruntRedirectOutput(t, cmd, &stdout, &stderr)375 output := stdout.String()376 errOutput := stderr.String()377 assert.True(t, strings.Contains(errOutput, testCase.expected) || strings.Contains(output, testCase.expected))378 }379}380// This tests terragrunt properly passes through terraform commands with sub commands381// and any number of specified args382func TestTerraformSubcommandCliArgs(t *testing.T) {383 t.Parallel()384 testCases := []struct {385 command []string386 expected string387 }{388 {389 []string{"force-unlock"},390 "terraform force-unlock",391 },392 {393 []string{"force-unlock", "foo"},394 "terraform force-unlock foo",395 },396 {397 []string{"force-unlock", "foo", "bar", "baz"},398 "terraform force-unlock foo bar baz",399 },400 {401 []string{"force-unlock", "foo", "bar", "baz", "foobar"},402 "terraform force-unlock foo bar baz foobar",403 },404 }405 for _, testCase := range testCases {406 cmd := fmt.Sprintf("terragrunt %s --terragrunt-non-interactive --terragrunt-working-dir %s", strings.Join(testCase.command, " "), TEST_FIXTURE_EXTRA_ARGS_PATH)407 var (408 stdout bytes.Buffer409 stderr bytes.Buffer410 )411 // Call runTerragruntCommand directly because this command contains failures (which causes runTerragruntRedirectOutput to abort) but we don't care.412 if err := runTerragruntCommand(t, cmd, &stdout, &stderr); err == nil {413 t.Fatalf("Failed to properly fail command: %v.", cmd)414 }415 output := stdout.String()416 errOutput := stderr.String()417 assert.True(t, strings.Contains(errOutput, testCase.expected) || strings.Contains(output, testCase.expected))418 }419}420func cleanupTerraformFolder(t *testing.T, templatesPath string) {421 removeFile(t, util.JoinPath(templatesPath, TERRAFORM_STATE))422 removeFile(t, util.JoinPath(templatesPath, TERRAFORM_STATE_BACKUP))423 removeFolder(t, util.JoinPath(templatesPath, TERRAFORM_FOLDER))424}425func removeFile(t *testing.T, path string) {426 if util.FileExists(path) {427 if err := os.Remove(path); err != nil {428 t.Fatalf("Error while removing %s: %v", path, err)429 }430 }431}432func removeFolder(t *testing.T, path string) {433 if util.FileExists(path) {434 if err := os.RemoveAll(path); err != nil {435 t.Fatalf("Error while removing %s: %v", path, err)436 }437 }438}439func runTerragruntCommand(t *testing.T, command string, writer io.Writer, errwriter io.Writer) error {440 args := strings.Split(command, " ")441 app := cli.CreateTerragruntCli("TEST", writer, errwriter)442 return app.Run(args)443}444func runTerragrunt(t *testing.T, command string) {445 runTerragruntRedirectOutput(t, command, os.Stdout, os.Stderr)446}447func runTerragruntRedirectOutput(t *testing.T, command string, writer io.Writer, errwriter io.Writer) {448 if err := runTerragruntCommand(t, command, writer, errwriter); err != nil {449 t.Fatalf("Failed to run Terragrunt command '%s' due to error: %s", command, err)450 }451}452func copyEnvironment(t *testing.T, environmentPath string) string {453 tmpDir, err := ioutil.TempDir("", "terragrunt-test")454 if err != nil {455 t.Fatalf("Failed to create temp dir due to error: %v", err)456 }457 t.Logf("Copying %s to %s", environmentPath, tmpDir)458 err = filepath.Walk(environmentPath, func(path string, info os.FileInfo, err error) error {459 if err != nil {460 return err461 }462 if info.IsDir() {463 return nil464 }465 destPath := util.JoinPath(tmpDir, path)466 destPathDir := filepath.Dir(destPath)467 if err := os.MkdirAll(destPathDir, 0777); err != nil {468 return err469 }470 return copyFile(path, destPath)471 })472 if err != nil {473 t.Fatalf("Error walking file path %s due to error: %v", environmentPath, err)474 }475 return tmpDir476}477func copyFile(srcPath string, destPath string) error {478 contents, err := ioutil.ReadFile(srcPath)479 if err != nil {480 return err481 }482 return ioutil.WriteFile(destPath, contents, 0644)483}484func createTmpTerragruntConfigWithParentAndChild(t *testing.T, parentPath string, childRelPath string, s3BucketName string, parentConfigFileName string, childConfigFileName string) string {485 tmpDir, err := ioutil.TempDir("", "terragrunt-parent-child-test")486 if err != nil {487 t.Fatalf("Failed to create temp dir due to error: %v", err)488 }489 childDestPath := util.JoinPath(tmpDir, childRelPath)490 if err := os.MkdirAll(childDestPath, 0777); err != nil {491 t.Fatalf("Failed to create temp dir %s due to error %v", childDestPath, err)492 }493 parentTerragruntSrcPath := util.JoinPath(parentPath, parentConfigFileName)494 parentTerragruntDestPath := util.JoinPath(tmpDir, parentConfigFileName)495 copyTerragruntConfigAndFillPlaceholders(t, parentTerragruntSrcPath, parentTerragruntDestPath, s3BucketName, "not-used")496 childTerragruntSrcPath := util.JoinPath(util.JoinPath(parentPath, childRelPath), childConfigFileName)497 childTerragruntDestPath := util.JoinPath(childDestPath, childConfigFileName)498 copyTerragruntConfigAndFillPlaceholders(t, childTerragruntSrcPath, childTerragruntDestPath, s3BucketName, "not-used")499 return childTerragruntDestPath500}501func createTmpTerragruntConfig(t *testing.T, templatesPath string, s3BucketName string, lockTableName string, configFileName string) string {502 tmpFolder, err := ioutil.TempDir("", "terragrunt-test")503 if err != nil {504 t.Fatalf("Failed to create temp folder due to error: %v", err)505 }506 tmpTerragruntConfigFile := util.JoinPath(tmpFolder, configFileName)507 originalTerragruntConfigPath := util.JoinPath(templatesPath, configFileName)508 copyTerragruntConfigAndFillPlaceholders(t, originalTerragruntConfigPath, tmpTerragruntConfigFile, s3BucketName, lockTableName)509 return tmpTerragruntConfigFile510}511func copyTerragruntConfigAndFillPlaceholders(t *testing.T, configSrcPath string, configDestPath string, s3BucketName string, lockTableName string) {512 contents, err := util.ReadFileAsString(configSrcPath)513 if err != nil {514 t.Fatalf("Error reading Terragrunt config at %s: %v", configSrcPath, err)515 }516 contents = strings.Replace(contents, "__FILL_IN_BUCKET_NAME__", s3BucketName, -1)517 contents = strings.Replace(contents, "__FILL_IN_LOCK_TABLE_NAME__", lockTableName, -1)518 if err := ioutil.WriteFile(configDestPath, []byte(contents), 0444); err != nil {519 t.Fatalf("Error writing temp Terragrunt config to %s: %v", configDestPath, err)520 }521}522// Returns a unique (ish) id we can attach to resources and tfstate files so they don't conflict with each other523// Uses base 62 to generate a 6 character string that's unlikely to collide with the handful of tests we run in524// parallel. Based on code here: http://stackoverflow.com/a/9543797/483528525func uniqueId() string {526 const BASE_62_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"527 const UNIQUE_ID_LENGTH = 6 // Should be good for 62^6 = 56+ billion combinations528 var out bytes.Buffer529 for i := 0; i < UNIQUE_ID_LENGTH; i++ {530 out.WriteByte(BASE_62_CHARS[rand.Intn(len(BASE_62_CHARS))])531 }532 return out.String()533}534// Check that the S3 Bucket of the given name and region exists. Terragrunt should create this bucket during the test.535func validateS3BucketExists(t *testing.T, awsRegion string, bucketName string) {536 mockOptions, err := options.NewTerragruntOptionsForTest("integration_test")537 if err != nil {538 t.Fatalf("Error creating mockOptions: %v", err)539 }540 s3Client, err := remote.CreateS3Client(awsRegion, "", "", "", mockOptions)541 if err != nil {542 t.Fatalf("Error creating S3 client: %v", err)543 }544 remoteStateConfig := remote.RemoteStateConfigS3{Bucket: bucketName, Region: awsRegion}545 assert.True(t, remote.DoesS3BucketExist(s3Client, &remoteStateConfig), "Terragrunt failed to create remote state S3 bucket %s", bucketName)546}547// Delete the specified S3 bucket to clean up after a test548func deleteS3Bucket(t *testing.T, awsRegion string, bucketName string) {549 mockOptions, err := options.NewTerragruntOptionsForTest("integration_test")550 if err != nil {551 t.Fatalf("Error creating mockOptions: %v", err)552 }553 s3Client, err := remote.CreateS3Client(awsRegion, "", "", "", mockOptions)554 if err != nil {555 t.Fatalf("Error creating S3 client: %v", err)556 }557 t.Logf("Deleting test s3 bucket %s", bucketName)558 out, err := s3Client.ListObjectVersions(&s3.ListObjectVersionsInput{Bucket: aws.String(bucketName)})559 if err != nil {560 t.Fatalf("Failed to list object versions in s3 bucket %s: %v", bucketName, err)561 }562 objectIdentifiers := []*s3.ObjectIdentifier{}563 for _, version := range out.Versions {564 objectIdentifiers = append(objectIdentifiers, &s3.ObjectIdentifier{565 Key: version.Key,566 VersionId: version.VersionId,567 })568 }569 if len(objectIdentifiers) > 0 {570 deleteInput := &s3.DeleteObjectsInput{571 Bucket: aws.String(bucketName),572 Delete: &s3.Delete{Objects: objectIdentifiers},573 }574 if _, err := s3Client.DeleteObjects(deleteInput); err != nil {575 t.Fatalf("Error deleting all versions of all objects in bucket %s: %v", bucketName, err)576 }577 }578 if _, err := s3Client.DeleteBucket(&s3.DeleteBucketInput{Bucket: aws.String(bucketName)}); err != nil {579 t.Fatalf("Failed to delete S3 bucket %s: %v", bucketName, err)580 }581}582// Create an authenticated client for DynamoDB583func createDynamoDbClient(awsRegion, awsProfile string, iamRoleArn string) (*dynamodb.DynamoDB, error) {584 mockOptions, err := options.NewTerragruntOptionsForTest("integration_test")585 if err != nil {586 return nil, err587 }588 session, err := aws_helper.CreateAwsSession(awsRegion, "", awsProfile, iamRoleArn, mockOptions)589 if err != nil {590 return nil, err591 }592 return dynamodb.New(session), nil593}594func createDynamoDbClientForTest(t *testing.T, awsRegion string) *dynamodb.DynamoDB {595 client, err := createDynamoDbClient(awsRegion, "", "")596 if err != nil {597 t.Fatal(err)598 }599 return client600}601func cleanupTableForTest(t *testing.T, tableName string, awsRegion string) {602 client := createDynamoDbClientForTest(t, awsRegion)603 err := terragruntDynamoDb.DeleteTable(tableName, client)604 assert.Nil(t, err, "Unexpected error: %v", err)605}...
integration_suite_test.go
Source:integration_suite_test.go
...150 content, err := os.ReadFile(f.PathToFixtureFile(pkg, target))151 ExpectWithOffset(1, err).NotTo(HaveOccurred())152 return string(content)153}154func (f FixtureManager) RemoveFile(pkg string, target string) {155 Expect(os.RemoveAll(f.PathTo(pkg, target))).To(Succeed())156}157func (f FixtureManager) PackageRoot() string {158 return "github.com/onsi/ginkgo/v2/integration/" + f.TmpDir159}160func (f FixtureManager) PackageNameFor(target string) string {161 return f.PackageRoot() + "/" + target162}163func sameFile(filePath, otherFilePath string) bool {164 content, readErr := os.ReadFile(filePath)165 Expect(readErr).NotTo(HaveOccurred())166 otherContent, readErr := os.ReadFile(otherFilePath)167 Expect(readErr).NotTo(HaveOccurred())168 Expect(string(content)).To(Equal(string(otherContent)))...
RemoveFile
Using AI Code Generation
1import (2func TestRemoveFile(t *testing.T) {3 if runtime.GOOS == "windows" {4 cmd = exec.Command(`C:\Go\bin\go.exe`, `run`, `1.go`)5 } else {6 cmd = exec.Command(`go`, `run`, `1.go`)7 }8 output, err = cmd.CombinedOutput()9 if err != nil {10 t.Error(err)11 }12 if !strings.Contains(output, "File removed") {13 t.Error("File not removed")14 }15}16import (17func TestMain(m *testing.M) {18 fmt.Println("Creating test file")19 f, err := os.Create("test.txt")20 if err != nil {21 fmt.Println(err)22 }23 f.Close()24 fmt.Println("Running tests")25 code := m.Run()26 fmt.Println("Removing test file")27 err = os.Remove("test.txt")28 if err != nil {29 fmt.Println(err)30 }31 os.Exit(code)32}33func TestIntegration(t *testing.T) {34 fmt.Println("Integration test")35}
RemoveFile
Using AI Code Generation
1import (2func main() {3 err := os.Remove("myFile.txt")4 if err != nil {5 fmt.Println(err)6 }7 fmt.Println("File Removed")8}9Related Posts: golang os.RemoveAll() example10golang os.Chmod() example11golang os.Chdir() ex
RemoveFile
Using AI Code Generation
1import (2func TestRemoveFile(t *testing.T) {3 f, err := os.OpenFile("test.txt", os.O_WRONLY|os.O_CREATE, 0666)4 f.Close()5 if err != nil {6 fmt.Println(err)7 }8 integration_test.RemoveFile("test.txt")9}10import (11func TestRemoveFile(t *testing.T) {12 f, err := os.OpenFile("test.txt", os.O_WRONLY|os.O_CREATE, 0666)13 f.Close()14 if err != nil {15 fmt.Println(err)16 }17 integration_test.RemoveFile("test.txt")18}19import (20func TestRemoveFile(t *testing.T) {21 f, err := os.OpenFile("test.txt", os.O_WRONLY|os.O_CREATE, 0666)22 f.Close()23 if err != nil {24 fmt.Println(err)25 }26 integration_test.RemoveFile("test.txt")27}28import (29func TestRemoveFile(t *testing.T) {30 f, err := os.OpenFile("test.txt", os.O_WRONLY|os.O_CREATE, 0666)31 f.Close()32 if err != nil {33 fmt.Println(err)34 }35 integration_test.RemoveFile("test.txt")36}37import (38func TestRemoveFile(t *testing.T) {39 f, err := os.OpenFile("test.txt", os.O_WRONLY|os.O_CREATE, 0666)40 f.Close()41 if err != nil {
RemoveFile
Using AI Code Generation
1import "testing"2func TestRemoveFile(t *testing.T) {3 err := integration_test.RemoveFile()4 if err != nil {5 t.Error("Error in RemoveFile")6 }7}8import (9func RemoveFile() error {10 err := os.Remove("file.txt")11 if err != nil {12 }13}14func TestRemoveFile(t *testing.T) {15 err := RemoveFile()16 if err != nil {17 t.Error("Error in RemoveFile")18 }19}
RemoveFile
Using AI Code Generation
1import (2func main() {3 fmt.Println("Hello World")4 integration_test.RemoveFile("test.txt")5}6import (7func RemoveFile(filename string) {8 err := os.Remove(filename)9 if err != nil {10 fmt.Println(err)11 }12}13 /usr/local/Cellar/go/1.11.2/libexec/src/../integration_test (from $GOROOT)14 /Users/username/go/src/../integration_test (from $GOPATH)15import (16func main() {17 file, err := os.Open("test.txt")18 if err != nil {19 log.Fatal(err)20 }21 defer file.Close()22 reader := bufio.NewReader(file)23 for {24 line, err := reader.ReadString('25 if err == io.EOF {26 } else if err != nil {27 log.Fatal(err)28 }29 fmt.Print(line)30 }31}
RemoveFile
Using AI Code Generation
1func TestRemoveFile(t *testing.T) {2 test := integration_test.NewIntegrationTest(t)3 test.RemoveFile("test.txt")4}5func TestRemoveFile(t *testing.T) {6 test := integration_test.NewIntegrationTest(t)7 test.RemoveFile("test.txt")8}9func TestRemoveFile(t *testing.T) {10 test := integration_test.NewIntegrationTest(t)11 test.RemoveFile("test.txt")12}13func TestRemoveFile(t *testing.T) {14 test := integration_test.NewIntegrationTest(t)15 test.RemoveFile("test.txt")16}17func TestRemoveFile(t *testing.T) {18 test := integration_test.NewIntegrationTest(t)19 test.RemoveFile("test.txt")20}21func TestRemoveFile(t *testing.T) {22 test := integration_test.NewIntegrationTest(t)23 test.RemoveFile("test.txt")24}
RemoveFile
Using AI Code Generation
1import "fmt"2import "integration_test"3func main() {4 fmt.Println("Hello, 世界")5 i.RemoveFile("temp.txt")6}7import "fmt"8import "os"9type Integration_test struct {10}11func (i Integration_test) RemoveFile(fileName string) {12 fmt.Println("Removing file " + fileName)13 err := os.Remove(fileName)14 if err != nil {15 fmt.Println(err)16 }17}
RemoveFile
Using AI Code Generation
1import (2func main() {3 fmt.Println(integration_test.RemoveFile("test.txt"))4}5import (6func main() {7 fmt.Println(integration_test.RemoveFile("test.txt"))8}9import (10func main() {11 fmt.Println(integration_test.RemoveFile("test.txt"))12}13import (14func main() {15 fmt.Println(integration_test.RemoveFile("test.txt"))16}17import (18func main() {19 fmt.Println(integration_test.RemoveFile("test.txt"))20}21import (22func main() {23 fmt.Println(integration_test.RemoveFile("test.txt"))24}25import (26func main() {27 fmt.Println(integration_test.RemoveFile("test.txt"))28}29import (30func main() {31 fmt.Println(integration_test.RemoveFile("test.txt"))32}33import (34func main() {35 fmt.Println(integration_test.RemoveFile
RemoveFile
Using AI Code Generation
1import (2func TestRemoveFile(t *testing.T) {3 test := integration_test{}4 test.RemoveFile("test.txt")5 fmt.Println("File removed successfully")6}7import (8func TestRemoveFile(t *testing.T) {9 test := integration_test{}10 test.RemoveFile("test.txt")11 fmt.Println("File removed successfully")12}13import (14func TestRemoveFile(t *testing.T) {15 test := integration_test{}16 test.RemoveFile("test.txt")17 fmt.Println("File removed successfully")18}19import (20func TestRemoveFile(t *testing.T) {21 test := integration_test{}22 test.RemoveFile("test.txt")23 fmt.Println("File removed successfully")24}25import (26func TestRemoveFile(t *testing.T) {27 test := integration_test{}28 test.RemoveFile("test.txt")29 fmt.Println("File removed successfully")30}31import (32func TestRemoveFile(t *testing.T) {33 test := integration_test{}34 test.RemoveFile("test.txt")35 fmt.Println("File removed successfully")36}37import (38func TestRemoveFile(t *testing.T) {39 test := integration_test{}40 test.RemoveFile("test.txt")41 fmt.Println("File removed successfully")42}43import (
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!