Skip to content

Commit bae7870

Browse files
bordeuxclaude
andcommitted
style: fix formatting issues for CI
Run cargo fmt to fix formatting in: - src/filter_functions/encoding.rs - tests/test_datetime_unit.rs - tests/test_encoding_functions.rs - tests/test_filters_integration.rs - tests/test_network_functions.rs 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent dae0758 commit bae7870

5 files changed

Lines changed: 73 additions & 22 deletions

File tree

src/filter_functions/encoding.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ impl FilterFunction for Base64Encode {
5050

5151
fn call_as_filter(value: &Value, _kwargs: Kwargs) -> Result<Value, Error> {
5252
let input = value.as_str().ok_or_else(|| {
53-
Error::new(ErrorKind::InvalidOperation, "base64_encode requires a string")
53+
Error::new(
54+
ErrorKind::InvalidOperation,
55+
"base64_encode requires a string",
56+
)
5457
})?;
5558
Ok(Value::from(Self::encode(input)))
5659
}
@@ -99,7 +102,10 @@ impl FilterFunction for Base64Decode {
99102

100103
fn call_as_filter(value: &Value, _kwargs: Kwargs) -> Result<Value, Error> {
101104
let input = value.as_str().ok_or_else(|| {
102-
Error::new(ErrorKind::InvalidOperation, "base64_decode requires a string")
105+
Error::new(
106+
ErrorKind::InvalidOperation,
107+
"base64_decode requires a string",
108+
)
103109
})?;
104110
Ok(Value::from(Self::decode(input)?))
105111
}
@@ -298,7 +304,10 @@ impl FilterFunction for EscapeShell {
298304

299305
fn call_as_filter(value: &Value, _kwargs: Kwargs) -> Result<Value, Error> {
300306
let input = value.as_str().ok_or_else(|| {
301-
Error::new(ErrorKind::InvalidOperation, "escape_shell requires a string")
307+
Error::new(
308+
ErrorKind::InvalidOperation,
309+
"escape_shell requires a string",
310+
)
302311
})?;
303312
Ok(Value::from(Self::escape(input)))
304313
}

tests/test_datetime_unit.rs

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,15 @@ fn test_now_fn_returns_timestamp() {
1818
let timestamp = result.as_i64().unwrap();
1919

2020
// Should be a reasonable Unix timestamp (after 2020-01-01)
21-
assert!(timestamp > 1577836800, "Timestamp should be after 2020-01-01");
21+
assert!(
22+
timestamp > 1577836800,
23+
"Timestamp should be after 2020-01-01"
24+
);
2225
// Should be before 2100-01-01
23-
assert!(timestamp < 4102444800, "Timestamp should be before 2100-01-01");
26+
assert!(
27+
timestamp < 4102444800,
28+
"Timestamp should be before 2100-01-01"
29+
);
2430
}
2531

2632
#[test]
@@ -29,7 +35,10 @@ fn test_now_fn_returns_integer() {
2935

3036
// Should be an integer, not a string
3137
assert!(result.as_i64().is_some(), "now() should return an integer");
32-
assert!(result.as_str().is_none(), "now() should not return a string");
38+
assert!(
39+
result.as_str().is_none(),
40+
"now() should not return a string"
41+
);
3342
}
3443

3544
#[test]
@@ -42,7 +51,12 @@ fn test_now_fn_monotonic() {
4251
let result2 = now_fn(empty_kwargs()).unwrap();
4352
let ts2 = result2.as_i64().unwrap();
4453

45-
assert!(ts2 >= ts1, "Timestamps should be monotonic: {} >= {}", ts2, ts1);
54+
assert!(
55+
ts2 >= ts1,
56+
"Timestamps should be monotonic: {} >= {}",
57+
ts2,
58+
ts1
59+
);
4660
}
4761

4862
// ==================== now() with format parameter ====================
@@ -55,8 +69,14 @@ fn test_now_fn_with_format_date_only() {
5569
// Should match YYYY-MM-DD pattern
5670
assert_eq!(formatted.len(), 10, "Date format should be 10 chars");
5771
assert!(formatted.contains('-'), "Should contain date separators");
58-
assert!(!formatted.contains('T'), "Should not contain time separator");
59-
assert!(!formatted.contains(':'), "Should not contain time separators");
72+
assert!(
73+
!formatted.contains('T'),
74+
"Should not contain time separator"
75+
);
76+
assert!(
77+
!formatted.contains(':'),
78+
"Should not contain time separators"
79+
);
6080
}
6181

6282
#[test]
@@ -66,7 +86,10 @@ fn test_now_fn_with_format_datetime() {
6686

6787
// Should match YYYY-MM-DD HH:MM:SS pattern (19 chars)
6888
assert_eq!(formatted.len(), 19, "DateTime format should be 19 chars");
69-
assert!(formatted.contains(' '), "Should contain space between date and time");
89+
assert!(
90+
formatted.contains(' '),
91+
"Should contain space between date and time"
92+
);
7093
assert!(formatted.contains(':'), "Should contain time separators");
7194
}
7295

@@ -87,15 +110,22 @@ fn test_now_fn_with_format_year_only() {
87110

88111
assert_eq!(formatted.len(), 4, "Year should be 4 digits");
89112
let year: i32 = formatted.parse().unwrap();
90-
assert!((2020..=2100).contains(&year), "Year should be reasonable: {}", year);
113+
assert!(
114+
(2020..=2100).contains(&year),
115+
"Year should be reasonable: {}",
116+
year
117+
);
91118
}
92119

93120
#[test]
94121
fn test_now_fn_with_format_returns_string() {
95122
let result = now_fn(kwargs_with_format("%Y-%m-%d")).unwrap();
96123

97124
// With format, should return a string
98-
assert!(result.as_str().is_some(), "now(format=...) should return a string");
125+
assert!(
126+
result.as_str().is_some(),
127+
"now(format=...) should return a string"
128+
);
99129
}
100130

101131
#[test]

tests/test_encoding_functions.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
66
use minijinja::value::Kwargs;
77
use minijinja::{Environment, Value};
8+
use tmpltool::filter_functions::FilterFunction;
89
use tmpltool::filter_functions::encoding::{
910
Base64Decode, Base64Encode, EscapeHtml, EscapeShell, EscapeXml, HexDecode, HexEncode,
1011
};
11-
use tmpltool::filter_functions::FilterFunction;
1212
use tmpltool::functions::encoding;
1313

1414
// Helper to test both function and filter syntax produce the same result
@@ -173,8 +173,7 @@ fn test_hex_encode_both_syntaxes() {
173173
#[test]
174174
fn test_hex_encode_empty() {
175175
let result =
176-
HexEncode::call_as_function(Kwargs::from_iter(vec![("string", Value::from(""))]))
177-
.unwrap();
176+
HexEncode::call_as_function(Kwargs::from_iter(vec![("string", Value::from(""))])).unwrap();
178177
assert_eq!(result.as_str().unwrap(), "");
179178
}
180179

@@ -317,8 +316,7 @@ fn test_escape_html_all_entities() {
317316
#[test]
318317
fn test_escape_html_empty() {
319318
let result =
320-
EscapeHtml::call_as_function(Kwargs::from_iter(vec![("string", Value::from(""))]))
321-
.unwrap();
319+
EscapeHtml::call_as_function(Kwargs::from_iter(vec![("string", Value::from(""))])).unwrap();
322320
assert_eq!(result.as_str().unwrap(), "");
323321
}
324322

tests/test_filters_integration.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,9 @@ SHA512: {{ "test" | sha512 }}"#;
293293
let output = fs::read_to_string(&output_path).unwrap();
294294
assert!(output.contains("MD5: 098f6bcd4621d373cade4e832627b4f6"));
295295
assert!(output.contains("SHA1: a94a8fe5ccb19ba61c4c0873d391e987982fbbd3"));
296-
assert!(output.contains("SHA256: 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"));
296+
assert!(
297+
output.contains("SHA256: 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08")
298+
);
297299
assert!(output.contains("SHA512: ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff"));
298300

299301
cleanup_test_file(&template_path);
@@ -416,7 +418,10 @@ fn test_escape_html_filter_in_template() {
416418
assert!(result.is_ok());
417419

418420
let output = fs::read_to_string(&output_path).unwrap();
419-
assert_eq!(output, "&lt;script&gt;alert(&#x27;XSS&#x27;)&lt;/script&gt;");
421+
assert_eq!(
422+
output,
423+
"&lt;script&gt;alert(&#x27;XSS&#x27;)&lt;/script&gt;"
424+
);
420425

421426
cleanup_test_file(&template_path);
422427
cleanup_test_file(&output_path);

tests/test_network_functions.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ fn test_get_interfaces_has_loopback() {
3030
}
3131
}
3232

33-
assert!(found_loopback, "Should have at least one loopback interface");
33+
assert!(
34+
found_loopback,
35+
"Should have at least one loopback interface"
36+
);
3437
}
3538

3639
#[test]
@@ -46,12 +49,18 @@ fn test_get_interfaces_has_required_fields() {
4649

4750
assert!(name.is_ok(), "Interface should have 'name' field");
4851
assert!(ip.is_ok(), "Interface should have 'ip' field");
49-
assert!(is_loopback.is_ok(), "Interface should have 'is_loopback' field");
52+
assert!(
53+
is_loopback.is_ok(),
54+
"Interface should have 'is_loopback' field"
55+
);
5056

5157
// Name should be a non-empty string
5258
let name_str = name.unwrap();
5359
assert!(name_str.as_str().is_some(), "Name should be a string");
54-
assert!(!name_str.as_str().unwrap().is_empty(), "Name should not be empty");
60+
assert!(
61+
!name_str.as_str().unwrap().is_empty(),
62+
"Name should not be empty"
63+
);
5564

5665
// IP should be a valid IP address
5766
let ip_str = ip.unwrap();

0 commit comments

Comments
 (0)