Skip to content

Commit

Permalink
Snapshot tests: Sort attachments by name & TODO
Browse files Browse the repository at this point in the history
* Avoid false positives on detecting changes due to changing in orders
  on attachments.
* TODO to remove cleaning up temporary files manually when cleanup
  improvements are merged.
  • Loading branch information
AmmarAbouZor committed Oct 29, 2024
1 parent bf2d97e commit 7144009
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ session_file:
- "1970-01-01T00:00:00Z\u0004ecu\u00040\u0004\u00040\u0004\u0004ecu2\u0004\u0004\u0004LogLevel INFO\u0004\u0005FLFI\u00051005083951\u0005FLFI"
- "1970-01-01T00:00:00Z\u0004ecu\u00040\u0004\u00040\u0004\u0004ecu3\u0004\u0004\u0004LogLevel INFO\u0004\u0005FLFI\u00052406339683\u0005FLFI"
attachments:
- filename: test1.txt
content:
- test1
- filename: test2.txt
content:
- test22
- filename: test3.txt
content:
- test333
- filename: test1.txt
content:
- test1
4 changes: 4 additions & 0 deletions application/apps/indexer/session/tests/snapshot_tests/utls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ impl SessionFiles {
attachments.extend(atts_iter);
}

attachments.sort_by(|att1, att2| att1.filename.cmp(&att2.filename));

Self {
session_file_lines,
attachments,
Expand All @@ -74,6 +76,8 @@ impl SessionFiles {
}

/// Remove session main file and attachments for the given session file.
/// TODO: This shouldn't be needed after the cleanup improvements are merged because the cleaning
/// up will be called automatically when the session is dropped.
pub fn cleanup_session_files(session_file: &PathBuf) {
std::fs::remove_file(session_file)
.expect("Removing generated temporary session file shouldn't fail");
Expand Down

0 comments on commit 7144009

Please sign in to comment.