Skip to content

Commit

Permalink
refactor:updated assert statements
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowHatpro committed Aug 26, 2024
1 parent ac3a346 commit fc32450
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 24 deletions.
1 change: 1 addition & 0 deletions src/archival/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ pub async fn set_status_with_message(
Ok(())
}

/// Job IDs that have permanent errors in `status_ext` will not be archived, hence we can remove them from `internet_archive_urls` table.
pub fn check_if_permanent_error(status_ext: &str) -> bool {
let permanent_errors = vec![
"error:bad-request",
Expand Down
36 changes: 12 additions & 24 deletions src/poller/tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,24 +373,15 @@ async fn test_should_insert_url_to_internet_archive_urls(pool: PgPool) -> Result
let url3 = "www.example2.com";
let url4 = "www.example.com";

assert_eq!(
should_insert_url_to_internet_archive_urls(url1, &pool)
.await
.unwrap(),
false
);
assert_eq!(
should_insert_url_to_internet_archive_urls(url2, &pool)
.await
.unwrap(),
true
);
assert_eq!(
should_insert_url_to_internet_archive_urls(url3, &pool)
.await
.unwrap(),
true
);
assert!(!should_insert_url_to_internet_archive_urls(url1, &pool)
.await
.unwrap());
assert!(should_insert_url_to_internet_archive_urls(url2, &pool)
.await
.unwrap());
assert!(should_insert_url_to_internet_archive_urls(url3, &pool)
.await
.unwrap());

sqlx::query("INSERT INTO external_url_archiver.internet_archive_urls
(id, url, job_id, from_table, from_table_id, created_at, retry_count, status, status_message)
Expand All @@ -399,12 +390,9 @@ async fn test_should_insert_url_to_internet_archive_urls(pool: PgPool) -> Result
.execute(&pool)
.await?;

assert_eq!(
should_insert_url_to_internet_archive_urls(url4, &pool)
.await
.unwrap(),
false
);
assert!(!should_insert_url_to_internet_archive_urls(url4, &pool)
.await
.unwrap());
Ok(())
}

Expand Down

0 comments on commit fc32450

Please sign in to comment.