Skip to content

Commit ee0c28b

Browse files
committed
Added test to track that version is invoked in unit with custom version
1 parent c2aab7e commit ee0c28b

File tree

8 files changed

+44
-0
lines changed

8 files changed

+44
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
variable "input_value" {}
2+
3+
output "output_value" {
4+
value = var.input_value
5+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
dependency "dependency" {
3+
config_path = "../dependency"
4+
}
5+
6+
dependency "dependency-with-custom-version" {
7+
config_path = "../dependency-with-custom-version"
8+
}
9+
10+
inputs = {
11+
input_value = dependency.dependency.outputs.result
12+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tofu 1.9.4
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output "result" {
2+
3+
value = "42"
4+
}

test/fixtures/version-invocation/dependency-with-custom-version/terragrunt.hcl

Whitespace-only changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output "result" {
2+
3+
value = "42"
4+
}

test/fixtures/version-invocation/dependency/terragrunt.hcl

Whitespace-only changes.

test/integration_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ const (
113113
testFixtureEphemeralInputs = "fixtures/ephemeral-inputs"
114114
testFixtureTfPath = "fixtures/tf-path"
115115
testFixtureTraceParent = "fixtures/trace-parent"
116+
testFixtureVersionInvocation = "fixtures/version-invocation"
116117

117118
terraformFolder = ".terraform"
118119

@@ -4153,3 +4154,20 @@ func TestVersionIsInvokedOnlyOnce(t *testing.T) {
41534154

41544155
assert.Len(t, matches, 1, "Expected exactly one occurrence of '-version' command, found %d", len(matches))
41554156
}
4157+
4158+
func TestVersionIsInvokedInDifferentDirectory(t *testing.T) {
4159+
t.Parallel()
4160+
4161+
tmpEnvPath := helpers.CopyEnvironment(t, testFixtureVersionInvocation)
4162+
helpers.CleanupTerraformFolder(t, tmpEnvPath)
4163+
testPath := util.JoinPath(tmpEnvPath, testFixtureVersionInvocation)
4164+
4165+
_, stderr, err := helpers.RunTerragruntCommandWithOutput(t, "terragrunt run --all --log-level trace --non-interactive --working-dir "+testPath+" -- apply")
4166+
require.NoError(t, err)
4167+
4168+
versionCmdPattern := regexp.MustCompile(`Running command: ` + regexp.QuoteMeta(wrappedBinary()) + ` -version`)
4169+
matches := versionCmdPattern.FindAllStringIndex(stderr, -1)
4170+
4171+
assert.Len(t, matches, 2, "Expected exactly one occurrence of '-version' command, found %d", len(matches))
4172+
assert.Contains(t, stderr, "prefix=dependency-with-custom-version msg=Running command: "+wrappedBinary()+" -version")
4173+
}

0 commit comments

Comments
 (0)