From bb3772e87e97e5895f0271116c238faf0895c17c Mon Sep 17 00:00:00 2001 From: Cameron Thornton Date: Mon, 17 Jun 2024 13:24:35 -0500 Subject: [PATCH] go rewrite - sort context map in test file (#10975) --- mmv1/templates/terraform/env_var_context.go.erb | 4 +++- .../terraform/examples/base_configs/test_file.go.erb | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mmv1/templates/terraform/env_var_context.go.erb b/mmv1/templates/terraform/env_var_context.go.erb index 3b7f28bbdb28..df6cef3c6854 100644 --- a/mmv1/templates/terraform/env_var_context.go.erb +++ b/mmv1/templates/terraform/env_var_context.go.erb @@ -1,4 +1,5 @@ -<% example.test_env_vars&.each do |var_name, var_type| -%> +<% unless example.test_env_vars.nil? -%> +<% example.test_env_vars.sort.each do |var_name, var_type| -%> <% if var_type == :ORG_ID -%> "<%= var_name -%>": envvar.GetTestOrgFromEnv(t), <% elsif var_type == :ORG_DOMAIN -%> @@ -29,3 +30,4 @@ "<%= var_name -%>": envvar.GetTestZoneFromEnv(), <% end -%> <% end -%> +<% end -%> diff --git a/mmv1/templates/terraform/examples/base_configs/test_file.go.erb b/mmv1/templates/terraform/examples/base_configs/test_file.go.erb index aeb0c5a31ca7..298046969e4f 100644 --- a/mmv1/templates/terraform/examples/base_configs/test_file.go.erb +++ b/mmv1/templates/terraform/examples/base_configs/test_file.go.erb @@ -67,7 +67,7 @@ func TestAcc<%= test_slug -%>(t *testing.T) { context := map[string]interface{} { <%= lines(indent(compile(pwd + '/templates/terraform/env_var_context.go.erb'), 4)) -%> <% unless example.test_vars_overrides.nil? -%> - <% example.test_vars_overrides.each do |var_name, override| -%> + <% example.test_vars_overrides.sort.each do |var_name, override| -%> "<%= var_name %>": <%= override %>, <% end -%> <% end -%>