File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,3 +31,30 @@ test_env_match() {
3131 assert_unsuccessful_code
3232 done
3333}
34+
35+ test_directory_flattening () {
36+ # Run the script directly to test the directory flattening logic
37+ cd example/
38+ output=$( bash ../stacks-gen-deps.sh dev-eu 1 network/vpc network/vpc/main.tf network/netplan.tf org/main.tf providers.tf network/vpc/subdir/below.tf)
39+
40+ # Check that nested files in the branch are flattened correctly
41+ assert_contains ' /network_vpc_main.tf: network/vpc/main.tf' " $output "
42+ assert_contains ' /network_netplan.tf: network/netplan.tf' " $output "
43+ assert_contains ' /providers.tf: providers.tf' " $output "
44+ assert_not_contains ' org/main.tf' " $output "
45+ assert_not_contains ' below' " $output "
46+ }
47+
48+ test_tfvars_precedence () {
49+ # Run the script to test tfvars parsing and precedence mapping
50+ cd example/
51+ output=$( bash ../stacks-gen-deps.sh dev-eu 1 network/vpc network/vpc/main.tf all.tfvars dev-eu.tfvars dev.tfvars network/all.tfvars network/dev-eu.tfvars network/eu.tfvars)
52+
53+ assert_contains ' /0-all-.auto.tfvars: all.tfvars' " $output "
54+ assert_contains ' /2-dev-.auto.tfvars: dev.tfvars' " $output "
55+ assert_contains ' /2-dev-eu-.auto.tfvars: dev-eu.tfvars' " $output "
56+ assert_contains ' /network_0-all-.auto.tfvars: network/all.tfvars' " $output "
57+ assert_contains ' /network_1-eu-.auto.tfvars: network/eu.tfvars' " $output "
58+ assert_contains ' /network_2-dev-eu-.auto.tfvars: network/dev-eu.tfvars' " $output "
59+ }
60+
You can’t perform that action at this time.
0 commit comments