Skip to content

Commit cae8402

Browse files
committed
refactor: [#227] rename test helpers in tofu project_generator.rs
Renamed 3 helper functions from test_* to fixture_* prefix to clarify they are test fixtures, not actual tests. Updated all call sites. Tests: All tests pass
1 parent 57727cc commit cae8402

File tree

1 file changed

+42
-42
lines changed

1 file changed

+42
-42
lines changed

src/infrastructure/templating/tofu/template/common/renderer/project_generator.rs

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -568,12 +568,12 @@ mod tests {
568568
use crate::shared::Username;
569569

570570
/// Test instance name for unit tests
571-
fn test_instance_name() -> InstanceName {
571+
fn fixture_instance_name() -> InstanceName {
572572
InstanceName::new("test-instance".to_string()).expect("Valid test instance name")
573573
}
574574

575575
/// Test profile name for unit tests
576-
fn test_profile_name() -> ProfileName {
576+
fn fixture_profile_name() -> ProfileName {
577577
ProfileName::new("test-profile".to_string()).expect("Valid test profile name")
578578
}
579579

@@ -598,10 +598,10 @@ mod tests {
598598
}
599599

600600
/// Helper function to create a test LXD provider config
601-
fn test_lxd_provider_config() -> ProviderConfig {
601+
fn fixture_lxd_provider_config() -> ProviderConfig {
602602
use crate::domain::provider::LxdConfig;
603603
ProviderConfig::Lxd(LxdConfig {
604-
profile_name: test_profile_name(),
604+
profile_name: fixture_profile_name(),
605605
})
606606
}
607607

@@ -617,8 +617,8 @@ mod tests {
617617
&build_path,
618618
ssh_credentials,
619619
22, // Default SSH port for tests
620-
test_instance_name(),
621-
test_lxd_provider_config(),
620+
fixture_instance_name(),
621+
fixture_lxd_provider_config(),
622622
);
623623

624624
assert_eq!(renderer.build_dir, build_path);
@@ -637,8 +637,8 @@ mod tests {
637637
&build_path,
638638
ssh_credentials,
639639
22, // Default SSH port for tests
640-
test_instance_name(),
641-
test_lxd_provider_config(),
640+
fixture_instance_name(),
641+
fixture_lxd_provider_config(),
642642
);
643643
let actual_path = renderer.build_opentofu_directory();
644644

@@ -657,8 +657,8 @@ mod tests {
657657
&build_path,
658658
ssh_credentials,
659659
22,
660-
test_instance_name(),
661-
test_lxd_provider_config(),
660+
fixture_instance_name(),
661+
fixture_lxd_provider_config(),
662662
);
663663
let template_path = renderer.build_template_path("main.tf");
664664

@@ -677,8 +677,8 @@ mod tests {
677677
&build_path,
678678
ssh_credentials,
679679
22,
680-
test_instance_name(),
681-
test_lxd_provider_config(),
680+
fixture_instance_name(),
681+
fixture_lxd_provider_config(),
682682
);
683683

684684
assert_eq!(
@@ -708,8 +708,8 @@ mod tests {
708708
&build_path,
709709
ssh_credentials,
710710
22,
711-
test_instance_name(),
712-
test_lxd_provider_config(),
711+
fixture_instance_name(),
712+
fixture_lxd_provider_config(),
713713
);
714714
let created_path = renderer
715715
.create_build_directory()
@@ -750,8 +750,8 @@ mod tests {
750750
&build_path,
751751
ssh_credentials,
752752
22,
753-
test_instance_name(),
754-
test_lxd_provider_config(),
753+
fixture_instance_name(),
754+
fixture_lxd_provider_config(),
755755
);
756756

757757
let result = renderer.create_build_directory().await;
@@ -788,8 +788,8 @@ mod tests {
788788
&build_path,
789789
ssh_credentials,
790790
22,
791-
test_instance_name(),
792-
test_lxd_provider_config(),
791+
fixture_instance_name(),
792+
fixture_lxd_provider_config(),
793793
);
794794

795795
// Try to copy a non-existent template
@@ -850,8 +850,8 @@ mod tests {
850850
temp_dir.path(),
851851
ssh_credentials,
852852
22,
853-
test_instance_name(),
854-
test_lxd_provider_config(),
853+
fixture_instance_name(),
854+
fixture_lxd_provider_config(),
855855
);
856856

857857
let result = renderer.copy_templates(&["test.tf"], &build_path).await;
@@ -881,8 +881,8 @@ mod tests {
881881
&build_path,
882882
ssh_credentials,
883883
22,
884-
test_instance_name(),
885-
test_lxd_provider_config(),
884+
fixture_instance_name(),
885+
fixture_lxd_provider_config(),
886886
);
887887
let template_path = renderer.build_template_path("");
888888
assert_eq!(template_path, "tofu/lxd/");
@@ -900,8 +900,8 @@ mod tests {
900900
&build_path,
901901
ssh_credentials,
902902
22,
903-
test_instance_name(),
904-
test_lxd_provider_config(),
903+
fixture_instance_name(),
904+
fixture_lxd_provider_config(),
905905
);
906906

907907
// File names with forward slashes should be handled literally
@@ -929,8 +929,8 @@ mod tests {
929929
&build_path,
930930
ssh_credentials,
931931
22,
932-
test_instance_name(),
933-
test_lxd_provider_config(),
932+
fixture_instance_name(),
933+
fixture_lxd_provider_config(),
934934
);
935935

936936
// File names with spaces
@@ -958,8 +958,8 @@ mod tests {
958958
&build_path,
959959
ssh_credentials,
960960
22,
961-
test_instance_name(),
962-
test_lxd_provider_config(),
961+
fixture_instance_name(),
962+
fixture_lxd_provider_config(),
963963
);
964964

965965
// Create a very long file name (300 characters)
@@ -988,8 +988,8 @@ mod tests {
988988
&build_path,
989989
ssh_credentials,
990990
22,
991-
test_instance_name(),
992-
test_lxd_provider_config(),
991+
fixture_instance_name(),
992+
fixture_lxd_provider_config(),
993993
);
994994
let created_path = renderer
995995
.create_build_directory()
@@ -1013,8 +1013,8 @@ mod tests {
10131013
&build_path,
10141014
ssh_credentials,
10151015
22,
1016-
test_instance_name(),
1017-
test_lxd_provider_config(),
1016+
fixture_instance_name(),
1017+
fixture_lxd_provider_config(),
10181018
);
10191019

10201020
// Should succeed with empty array
@@ -1051,8 +1051,8 @@ mod tests {
10511051
temp_dir.path(),
10521052
ssh_credentials,
10531053
22,
1054-
test_instance_name(),
1055-
test_lxd_provider_config(),
1054+
fixture_instance_name(),
1055+
fixture_lxd_provider_config(),
10561056
);
10571057

10581058
// Copy the same file twice - should succeed (overwrite)
@@ -1100,17 +1100,17 @@ mod tests {
11001100
&build_path1,
11011101
ssh_credentials1,
11021102
22,
1103-
test_instance_name(),
1104-
test_lxd_provider_config(),
1103+
fixture_instance_name(),
1104+
fixture_lxd_provider_config(),
11051105
);
11061106
let ssh_credentials2 = create_dummy_ssh_credentials(temp_dir.path());
11071107
let renderer2 = TofuProjectGenerator::new(
11081108
template_manager,
11091109
&build_path2,
11101110
ssh_credentials2,
11111111
22,
1112-
test_instance_name(),
1113-
test_lxd_provider_config(),
1112+
fixture_instance_name(),
1113+
fixture_lxd_provider_config(),
11141114
);
11151115

11161116
tokio::fs::create_dir_all(&build_path1)
@@ -1169,8 +1169,8 @@ mod tests {
11691169
temp_dir.path(),
11701170
ssh_credentials,
11711171
22,
1172-
test_instance_name(),
1173-
test_lxd_provider_config(),
1172+
fixture_instance_name(),
1173+
fixture_lxd_provider_config(),
11741174
);
11751175

11761176
// Try to copy both existing and non-existing files
@@ -1229,8 +1229,8 @@ mod tests {
12291229
temp_dir.path(),
12301230
ssh_credentials,
12311231
22,
1232-
test_instance_name(),
1233-
test_lxd_provider_config(),
1232+
fixture_instance_name(),
1233+
fixture_lxd_provider_config(),
12341234
);
12351235

12361236
let file_refs: Vec<&str> = file_names.iter().map(std::string::String::as_str).collect();

0 commit comments

Comments
 (0)