func initAndApplyAndIdempotentTest()

in e2etest.go [66:100]


func initAndApplyAndIdempotentTest(t testingT, moduleRootPath string, exampleRelativePath string, option terraform.Options, skipDestroy bool, skipCheckIdempotent bool, assertion func(*testing.T, TerraformOutput), executor testExecutor) {
	tryParallel(t)
	defer executor.TearDown(t, moduleRootPath, exampleRelativePath)
	testDir := filepath.Join(moduleRootPath, exampleRelativePath)
	logger.Log(t, fmt.Sprintf("===> Starting test for %s, since we're running tests in parallel, the test log will be buffered and output to stdout after the test was finished.", testDir))

	tmpDir := copyTerraformFolderToTemp(t, moduleRootPath, exampleRelativePath)
	defer func() {
		_ = os.RemoveAll(filepath.Clean(tmpDir))
	}()
	option.TerraformDir = tmpDir

	l := executor.Logger()
	c, ok := l.(io.Closer)
	if ok {
		defer func() {
			_ = c.Close()
		}()
	}
	option.Logger = logger.New(l)
	option = setupRetryLogic(option)

	if !skipDestroy {
		defer destroy(t, option)
	}
	initAndApply(t, &option)
	var err error
	if !skipCheckIdempotent {
		err = initAndPlanAndIdempotentAtEasyMode(t, option)
	}
	require.NoError(t, err)
	if assertion != nil {
		assertion(t.T(), terraform.OutputAll(t, removeLogger(option)))
	}
}