Skip to content

Commit

Permalink
Fix unit test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmichalis committed Jan 29, 2025
1 parent 901ac01 commit 5cabb80
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/url/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ mod tests {

#[test]
fn test_get_data_url_content_json() {
let data_url = "data:application/json;base64,eyJuYW1lIjogIlRlc3QifQ==";
let (content, ext) = get_data_url_content(data_url).unwrap();
assert_eq!(String::from_utf8_lossy(&content), r#"{"name": "Test"}"#);
assert_eq!(ext, "json");
let data_url = "data:application/json;base64,eyAidGVzdCI6IDEyMyB9"; // base64 encoded '{ "test": 123 }'
let (content, mime_type) = get_data_url_content(data_url).unwrap();
assert_eq!(String::from_utf8_lossy(&content), "{ \"test\": 123 }");
assert_eq!(mime_type, "application/json");
}

#[test]
Expand Down Expand Up @@ -212,8 +212,9 @@ mod tests {

#[test]
fn test_get_data_url_content_empty_mime() {
let (content, ext) = get_data_url_content("data:;base64,SGVsbG8=").unwrap();
assert_eq!(content, b"Hello");
assert_eq!(ext, "bin");
let data_url = "data:;base64,dGVzdCBjb250ZW50"; // base64 encoded 'test content'
let (content, mime_type) = get_data_url_content(data_url).unwrap();
assert_eq!(String::from_utf8_lossy(&content), "test content");
assert_eq!(mime_type, "application/octet-stream");
}
}

0 comments on commit 5cabb80

Please sign in to comment.