-
Notifications
You must be signed in to change notification settings - Fork 10
#41: update_one
tests
#52
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -904,4 +904,23 @@ mod tests { | |
assert!(new2 > old2); | ||
assert!(new2 > new1); | ||
} | ||
|
||
#[test] | ||
fn should_correctly_update_one_resource() { | ||
run_test_and_clean_up(|path| { | ||
create_file_at(path.clone(), Some(FILE_SIZE_1), Some(FILE_NAME_1)); | ||
create_file_at(path.clone(), Some(FILE_SIZE_2), Some(FILE_NAME_2)); | ||
let mut actual = ResourceIndex::build(path.clone()); | ||
let mut file_path = path.clone(); | ||
file_path.push(FILE_NAME_1); | ||
let old_id = ResourceId { | ||
data_size: FILE_SIZE_1, | ||
crc32: CRC32_1, | ||
}; | ||
let path_buf = CanonicalPathBuf::canonicalize(&file_path).unwrap(); | ||
let update = actual | ||
.update_one(path_buf.clone(), old_id) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now I'm curious what happens if a user of the lib passes wrong |
||
.expect("Should update one resource correctly"); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this current scenario, the update should be empty (nothing changed). Probably reasoning with paths instead of files would be better here:
Please, double-check. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Notion of a "file" is confusing here because it is combination of path and content, but index works with paths and contents separately. A "resource" is an identified content, a "path" it's current location. |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idea for a test case:
root/A
androot/B
.root/C
.update_one("root/C", id)
.Two cases:
a)
id
matches the content of new resourceb)
id
does notThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, alright. Should it replace the current one or is it a new unittest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New one