Skip to content

Commit bd02af8

Browse files
authored
refactor: update log output formatting in tests for clarity (#786)
1 parent 2066d5d commit bd02af8

File tree

1 file changed

+13
-14
lines changed
  • core/src/ten_manager/tests/test_case/fs

1 file changed

+13
-14
lines changed

core/src/ten_manager/tests/test_case/fs/mod.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ mod tests {
4242

4343
// Get the first chunk.
4444
let chunk = stream.next().await.expect("Should receive data")?;
45-
println!("chunk: {:?}", chunk);
45+
println!("chunk 1: {:?}", chunk);
4646
assert_eq!(chunk.line, test_content);
4747

4848
// Write more content to the file.
@@ -52,7 +52,7 @@ mod tests {
5252

5353
// Get the second chunk.
5454
let chunk = stream.next().await;
55-
println!("chunk: {:?}", chunk);
55+
println!("chunk 2: {:?}", chunk);
5656
match chunk {
5757
Some(chunk) => match chunk {
5858
Ok(chunk) => assert_eq!(chunk.line, more_content),
@@ -102,7 +102,7 @@ mod tests {
102102

103103
// Get the first chunk
104104
let chunk = stream.next().await.expect("Should receive data")?;
105-
println!("chunk: {:?}", chunk);
105+
println!("chunk 1: {:?}", chunk);
106106
assert_eq!(chunk.line, "Initial content");
107107

108108
// Simulate log rotation - delete and recreate file
@@ -124,7 +124,7 @@ mod tests {
124124
// Get the content after rotation
125125
let chunk =
126126
stream.next().await.expect("Should receive rotated data")?;
127-
println!("chunk: {:?}", chunk);
127+
println!("chunk 2: {:?}", chunk);
128128
assert_eq!(chunk.line, "Rotated content");
129129

130130
// Stop watching
@@ -156,7 +156,7 @@ mod tests {
156156

157157
// Get the first chunk.
158158
let chunk = stream.next().await.expect("Should receive data")?;
159-
println!("chunk: {:?}", chunk);
159+
println!("chunk 1: {:?}", chunk);
160160
assert_eq!(chunk.line, "Test content");
161161

162162
// Wait for the timeout to occur (no new content being written).
@@ -195,16 +195,15 @@ mod tests {
195195
\"msgpack://127.0.0.1:8001/\", \"graph name\": \"\", \"graph \
196196
id\": \"38097178-1712-4562-b60d-8e6ab15ba0cf\", \
197197
\"extension_threads\": {\"1713045\": {\"extensions\": \
198-
[\"test_extension\"]}}}";
198+
[\"test_extension\"]}}}\n";
199199

200200
temp_file.write_all(graph_resources_with_thread.as_bytes())?;
201-
temp_file.write_all(b"\n")?;
202201
temp_file.flush()?;
203202

204203
// Get the graph resources line
205204
let chunk =
206205
stream.next().await.expect("Should receive graph resources")?;
207-
println!("chunk: {:?}", chunk);
206+
println!("chunk 1: {:?}", chunk);
208207
assert!(chunk.line.contains("[graph resources]"));
209208

210209
// Now write logs that contain extension metadata in format
@@ -225,27 +224,27 @@ mod tests {
225224
.next()
226225
.await
227226
.expect("Should receive log with extension")?;
228-
println!("chunk: {:?}", chunk);
227+
println!("chunk 2: {:?}", chunk);
229228
assert!(chunk.line.contains("on_start()"));
230229

231230
// The metadata should include the extension name
232231
assert!(chunk.metadata.is_some(), "Should have metadata");
233232
let metadata = chunk.metadata.unwrap();
234-
println!("metadata: {:?}", metadata);
233+
println!("metadata 2: {:?}", metadata);
235234
assert_eq!(metadata.extension, Some("test_extension".to_string()));
236235

237236
// Get second log with extension metadata
238237
let chunk = stream
239238
.next()
240239
.await
241240
.expect("Should receive log with extension")?;
242-
println!("chunk: {:?}", chunk);
241+
println!("chunk 3: {:?}", chunk);
243242
assert!(chunk.line.contains("on_start() done"));
244243

245244
// The metadata should include the extension name
246245
assert!(chunk.metadata.is_some(), "Should have metadata");
247246
let metadata = chunk.metadata.unwrap();
248-
println!("metadata: {:?}", metadata);
247+
println!("metadata 3: {:?}", metadata);
249248
assert_eq!(metadata.extension, Some("test_extension".to_string()));
250249

251250
// Stop watching
@@ -376,10 +375,9 @@ mod tests {
376375
05-02 22:23:37.535 1713000(1713002) D \
377376
ten_protocol_integrated_on_close@close.c:107 \
378377
[2b11c6a8-9a63-4e9e-b18a-92456dee49d5] Integrated protocol \
379-
can be closed now";
378+
can be closed now\n";
380379

381380
temp_file.write_all(complete_log.as_bytes())?;
382-
temp_file.write_all(b"\n")?;
383381
temp_file.flush()?;
384382

385383
// We need to iterate through all log lines to find the specific
@@ -395,6 +393,7 @@ mod tests {
395393
// Process all log lines
396394
while let Some(result) = stream.next().await {
397395
let chunk = result?;
396+
println!("chunk: {:?}", chunk);
398397

399398
// Check if this is one of our target lines
400399
if chunk.line.contains(target_start_line)

0 commit comments

Comments
 (0)