-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add tests for ForceUnlock * add compatibility code for dir arg * generate lock id error for all backend types
- Loading branch information
Showing
4 changed files
with
103 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package tfexec | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-exec/tfexec/internal/testutil" | ||
) | ||
|
||
func TestForceUnlockCmd(t *testing.T) { | ||
td := t.TempDir() | ||
|
||
tf, err := NewTerraform(td, tfVersion(t, testutil.Latest_v1_1)) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
// empty env, to avoid environ mismatch in testing | ||
tf.SetEnv(map[string]string{}) | ||
|
||
t.Run("defaults", func(t *testing.T) { | ||
forceUnlockCmd, err := tf.forceUnlockCmd(context.Background(), "12345") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
assertCmd(t, []string{ | ||
"force-unlock", | ||
"-no-color", | ||
"-force", | ||
"12345", | ||
}, nil, forceUnlockCmd) | ||
}) | ||
} | ||
|
||
// The optional final positional [DIR] argument is available | ||
// until v0.15.0. | ||
func TestForceUnlockCmd_pre015(t *testing.T) { | ||
td := t.TempDir() | ||
|
||
tf, err := NewTerraform(td, tfVersion(t, testutil.Latest014)) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
// empty env, to avoid environ mismatch in testing | ||
tf.SetEnv(map[string]string{}) | ||
|
||
t.Run("override all defaults", func(t *testing.T) { | ||
forceUnlockCmd, err := tf.forceUnlockCmd(context.Background(), "12345", Dir("mydir")) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
assertCmd(t, []string{ | ||
"force-unlock", | ||
"-no-color", | ||
"-force", | ||
"12345", | ||
"mydir", | ||
}, nil, forceUnlockCmd) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters