Skip to content

Commit 81b11cb

Browse files
committed
refactor: rename test functions to use it_should_ convention
Replace test_ prefix with descriptive it_should_ names following BDD style: - test_undefined_variable_error → it_should_fail_when_template_references_undefined_variable - test_inventory_template_creation → it_should_create_inventory_template_successfully - test_invalid_ip_address → it_should_reject_invalid_ip_address - And 15 other test functions renamed for better readability All tests continue to pass with the new naming convention.
1 parent 5b63a0f commit 81b11cb

File tree

1 file changed

+18
-18
lines changed
  • src/template/wrappers/ansible/inventory

1 file changed

+18
-18
lines changed

src/template/wrappers/ansible/inventory/mod.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ mod tests {
228228
use super::*;
229229

230230
#[test]
231-
fn test_inventory_template_creation() {
231+
fn it_should_create_inventory_template_successfully() {
232232
// Use template content directly instead of file
233233
let template_content = "[all]\nserver ansible_host={{ansible_host}} ansible_ssh_private_key_file={{ansible_ssh_private_key_file}}\n";
234234

@@ -248,7 +248,7 @@ mod tests {
248248
}
249249

250250
#[test]
251-
fn test_inventory_template_context_generation() {
251+
fn it_should_generate_inventory_template_context() {
252252
// Use template content directly instead of file
253253
let template_content = "[all]\nserver ansible_host={{ansible_host}} ansible_ssh_private_key_file={{ansible_ssh_private_key_file}}\n";
254254

@@ -271,7 +271,7 @@ mod tests {
271271
}
272272

273273
#[test]
274-
fn test_empty_template_content() {
274+
fn it_should_accept_empty_template_content() {
275275
// Test with empty template content
276276
let template_file = File::new("inventory.yml.tera", String::new()).unwrap();
277277

@@ -291,7 +291,7 @@ mod tests {
291291
}
292292

293293
#[test]
294-
fn test_missing_placeholder() {
294+
fn it_should_work_with_missing_placeholder_variables() {
295295
// Create template content with only one placeholder
296296
let template_content = "[all]\nserver ansible_host={{ansible_host}}\n";
297297

@@ -313,7 +313,7 @@ mod tests {
313313
}
314314

315315
#[test]
316-
fn test_early_error_detection_both_variables_missing() {
316+
fn it_should_accept_static_template_with_no_variables() {
317317
// Create template content with no placeholder variables at all
318318
let template_content = "[all]\nserver ansible_host=192.168.1.1\n";
319319

@@ -335,7 +335,7 @@ mod tests {
335335
}
336336

337337
#[test]
338-
fn test_undefined_variable_error() {
338+
fn it_should_fail_when_template_references_undefined_variable() {
339339
// Create template content that references an undefined variable
340340
let template_content = "[all]\nserver ansible_host={{undefined_variable}}\n";
341341

@@ -360,7 +360,7 @@ mod tests {
360360
}
361361

362362
#[test]
363-
fn test_early_error_detection_template_validation_fails() {
363+
fn it_should_fail_when_template_validation_fails() {
364364
// Create template content with malformed Tera syntax
365365
let template_content = "[all]\nserver ansible_host={{ansible_host}} ansible_ssh_private_key_file={{ansible_ssh_private_key_file}}\nmalformed={{unclosed_var\n";
366366

@@ -380,7 +380,7 @@ mod tests {
380380
}
381381

382382
#[test]
383-
fn test_early_error_detection_malformed_syntax() {
383+
fn it_should_fail_when_template_has_malformed_syntax() {
384384
// Test with different malformed template syntax
385385
let template_content = "invalid {{{{ syntax";
386386

@@ -399,7 +399,7 @@ mod tests {
399399
}
400400

401401
#[test]
402-
fn test_template_validation_at_construction() {
402+
fn it_should_validate_template_at_construction_time() {
403403
// Create valid template content
404404
let template_content = "[all]\nserver ansible_host={{ansible_host}} ansible_ssh_private_key_file={{ansible_ssh_private_key_file}}\n";
405405

@@ -424,7 +424,7 @@ mod tests {
424424
}
425425

426426
#[test]
427-
fn test_invalid_ip_address() {
427+
fn it_should_reject_invalid_ip_address() {
428428
// Test that invalid IP addresses are rejected by the AnsibleHost wrapper
429429
let result = AnsibleHost::from_str("invalid-ip");
430430

@@ -434,7 +434,7 @@ mod tests {
434434
}
435435

436436
#[test]
437-
fn test_valid_ipv4_address() {
437+
fn it_should_accept_valid_ipv4_address() {
438438
// Test valid IPv4 address
439439
let host = AnsibleHost::from_str("192.168.1.100").unwrap();
440440
let ssh_key = SshPrivateKeyFile::new("/path/to/key").unwrap();
@@ -447,7 +447,7 @@ mod tests {
447447
}
448448

449449
#[test]
450-
fn test_valid_ipv6_address() {
450+
fn it_should_accept_valid_ipv6_address() {
451451
// Test valid IPv6 address
452452
let host = AnsibleHost::from_str("2001:db8::1").unwrap();
453453
let ssh_key = SshPrivateKeyFile::new("/path/to/key").unwrap();
@@ -460,7 +460,7 @@ mod tests {
460460
}
461461

462462
#[test]
463-
fn test_wrapper_types() {
463+
fn it_should_provide_access_to_wrapper_types() {
464464
let host = AnsibleHost::from_str("10.0.0.1").unwrap();
465465
let ssh_key = SshPrivateKeyFile::new("/path/to/key").unwrap();
466466
let context = InventoryContext::builder()
@@ -478,7 +478,7 @@ mod tests {
478478
}
479479

480480
#[test]
481-
fn test_builder_pattern_fluent_interface() {
481+
fn it_should_support_builder_pattern_fluent_interface() {
482482
// Test the fluent builder interface as requested
483483
let host = AnsibleHost::from_str("192.168.1.100").unwrap();
484484
let ssh_key = SshPrivateKeyFile::new("/home/user/.ssh/id_rsa").unwrap();
@@ -496,7 +496,7 @@ mod tests {
496496
}
497497

498498
#[test]
499-
fn test_builder_with_typed_parameters() {
499+
fn it_should_work_with_builder_typed_parameters() {
500500
// Test builder with typed parameters instead of strings
501501
let host = AnsibleHost::from_str("10.0.0.1").unwrap();
502502
let ssh_key = SshPrivateKeyFile::new("/path/to/key").unwrap();
@@ -515,7 +515,7 @@ mod tests {
515515
}
516516

517517
#[test]
518-
fn test_builder_missing_host_error() {
518+
fn it_should_fail_when_builder_missing_host() {
519519
// Test that builder fails when host is missing
520520
let ssh_key = SshPrivateKeyFile::new("/path/to/key").unwrap();
521521
let result = InventoryContext::builder()
@@ -528,7 +528,7 @@ mod tests {
528528
}
529529

530530
#[test]
531-
fn test_builder_missing_ssh_key_error() {
531+
fn it_should_fail_when_builder_missing_ssh_key() {
532532
// Test that builder fails when SSH key is missing
533533
let host = AnsibleHost::from_str("192.168.1.100").unwrap();
534534
let result = InventoryContext::builder().with_host(host).build();
@@ -539,7 +539,7 @@ mod tests {
539539
}
540540

541541
#[test]
542-
fn test_new_with_typed_parameters() {
542+
fn it_should_create_new_inventory_context_with_typed_parameters() {
543543
// Test the new direct constructor with typed parameters
544544
let host = AnsibleHost::from_str("192.168.1.50").unwrap();
545545
let ssh_key = SshPrivateKeyFile::new("/etc/ssh/test_key").unwrap();

0 commit comments

Comments
 (0)