github.com/opentofu/opentofu@v1.7.1/internal/cloud/e2e/apply_no_input_flag_test.go (about) 1 // Copyright (c) The OpenTofu Authors 2 // SPDX-License-Identifier: MPL-2.0 3 // Copyright (c) 2023 HashiCorp, Inc. 4 // SPDX-License-Identifier: MPL-2.0 5 6 package main 7 8 import ( 9 "testing" 10 ) 11 12 func Test_apply_no_input_flag(t *testing.T) { 13 t.Parallel() 14 skipIfMissingEnvVar(t) 15 16 cases := testCases{ 17 "terraform apply with -input=false": { 18 operations: []operationSets{ 19 { 20 prep: func(t *testing.T, orgName, dir string) { 21 wsName := "new-workspace" 22 tfBlock := terraformConfigCloudBackendName(orgName, wsName) 23 writeMainTF(t, tfBlock, dir) 24 }, 25 commands: []tfCommand{ 26 { 27 command: []string{"init", "-input=false"}, 28 expectedCmdOutput: `Terraform Cloud has been successfully initialized`, 29 }, 30 { 31 command: []string{"apply", "-input=false"}, 32 expectedCmdOutput: `Cannot confirm apply due to -input=false. Please handle run confirmation in the UI.`, 33 expectError: true, 34 }, 35 }, 36 }, 37 }, 38 }, 39 "terraform apply with auto approve and -input=false": { 40 operations: []operationSets{ 41 { 42 prep: func(t *testing.T, orgName, dir string) { 43 wsName := "cloud-workspace" 44 tfBlock := terraformConfigCloudBackendName(orgName, wsName) 45 writeMainTF(t, tfBlock, dir) 46 }, 47 commands: []tfCommand{ 48 { 49 command: []string{"init", "-input=false"}, 50 expectedCmdOutput: `Terraform Cloud has been successfully initialized`, 51 }, 52 { 53 command: []string{"apply", "-auto-approve", "-input=false"}, 54 expectedCmdOutput: `Apply complete!`, 55 }, 56 }, 57 }, 58 }, 59 }, 60 } 61 62 testRunner(t, cases, 1) 63 }