-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(apub/collection): fix total pages
- Loading branch information
Showing
5 changed files
with
47 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use hatsu_apub::collections::{ | ||
Collection, | ||
// TODO: test collection page | ||
// CollectionPage | ||
}; | ||
use hatsu_utils::AppError; | ||
use url::Url; | ||
|
||
#[test] | ||
fn new_collection() -> Result<(), AppError> { | ||
let collection_id = Url::parse("https://hatsu.local/collections/test1")?; | ||
let collection = Collection::new(&collection_id, 100, 10)?; | ||
|
||
let expected_first_url = Url::parse("https://hatsu.local/collections/test1?page=1")?; | ||
let expected_last_url = Url::parse("https://hatsu.local/collections/test1?page=10")?; | ||
|
||
assert_eq!(collection.first, expected_first_url); | ||
assert_eq!(collection.last, expected_last_url); | ||
|
||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn new_empty_collection() -> Result<(), AppError> { | ||
let collection_id = Url::parse("https://hatsu.local/collections/test2")?; | ||
let collection = Collection::new(&collection_id, 0, 0)?; | ||
|
||
let expected_url = Url::parse("https://hatsu.local/collections/test2?page=1")?; | ||
|
||
assert_eq!(collection.first, expected_url); | ||
assert_eq!(collection.last, expected_url); | ||
|
||
Ok(()) | ||
} |