|
1 |
| -use wp_api::{post_revisions::PostRevisionListParams, posts::PostId}; |
| 1 | +use wp_api::{ |
| 2 | + post_revisions::{PostRevisionId, PostRevisionListParams}, |
| 3 | + posts::PostId, |
| 4 | +}; |
2 | 5 | use wp_api_integration_tests::prelude::*;
|
3 | 6 |
|
4 | 7 | #[tokio::test]
|
@@ -27,6 +30,66 @@ async fn list_err_revision_invalid_offset_number() {
|
27 | 30 | .assert_wp_error(WpErrorCode::RevisionInvalidOffsetNumber)
|
28 | 31 | }
|
29 | 32 |
|
| 33 | +#[tokio::test] |
| 34 | +#[parallel] |
| 35 | +async fn list_err_revision_invalid_page_number() { |
| 36 | + api_client() |
| 37 | + .post_revisions() |
| 38 | + .list_with_edit_context( |
| 39 | + &revisioned_post_id(), |
| 40 | + &PostRevisionListParams { |
| 41 | + page: Some(99999999), |
| 42 | + ..Default::default() |
| 43 | + }, |
| 44 | + ) |
| 45 | + .await |
| 46 | + .assert_wp_error(WpErrorCode::RevisionInvalidPageNumber) |
| 47 | +} |
| 48 | + |
| 49 | +#[tokio::test] |
| 50 | +#[parallel] |
| 51 | +async fn retrieve_err_post_invalid_parent() { |
| 52 | + api_client() |
| 53 | + .post_revisions() |
| 54 | + .retrieve_with_edit_context(&PostId(99999999), &valid_revision_id()) |
| 55 | + .await |
| 56 | + .assert_wp_error(WpErrorCode::PostInvalidParent) |
| 57 | +} |
| 58 | + |
| 59 | +#[tokio::test] |
| 60 | +#[parallel] |
| 61 | +async fn retrieve_err_post_invalid_id() { |
| 62 | + api_client() |
| 63 | + .post_revisions() |
| 64 | + .retrieve_with_edit_context(&revisioned_post_id(), &PostRevisionId(99999999)) |
| 65 | + .await |
| 66 | + .assert_wp_error(WpErrorCode::PostInvalidId) |
| 67 | +} |
| 68 | + |
| 69 | +#[tokio::test] |
| 70 | +#[parallel] |
| 71 | +async fn delete_err_post_invalid_parent() { |
| 72 | + api_client() |
| 73 | + .post_revisions() |
| 74 | + .delete(&PostId(99999999), &valid_revision_id()) |
| 75 | + .await |
| 76 | + .assert_wp_error(WpErrorCode::PostInvalidParent) |
| 77 | +} |
| 78 | + |
| 79 | +#[tokio::test] |
| 80 | +#[parallel] |
| 81 | +async fn delete_err_post_invalid_id() { |
| 82 | + api_client() |
| 83 | + .post_revisions() |
| 84 | + .delete(&revisioned_post_id(), &PostRevisionId(99999999)) |
| 85 | + .await |
| 86 | + .assert_wp_error(WpErrorCode::PostInvalidId) |
| 87 | +} |
| 88 | + |
30 | 89 | fn revisioned_post_id() -> PostId {
|
31 | 90 | PostId(TestCredentials::instance().revisioned_post_id)
|
32 | 91 | }
|
| 92 | + |
| 93 | +fn valid_revision_id() -> PostRevisionId { |
| 94 | + PostRevisionId(TestCredentials::instance().revision_id_for_revisioned_post_id) |
| 95 | +} |
0 commit comments