aboutsummaryrefslogtreecommitdiffstats
path: root/rust
diff options
context:
space:
mode:
Diffstat (limited to 'rust')
-rw-r--r--rust/tests/helpers.rs3
-rw-r--r--rust/tests/test_api_server_http.rs150
2 files changed, 152 insertions, 1 deletions
diff --git a/rust/tests/helpers.rs b/rust/tests/helpers.rs
index 6f12faaa..f4cd93e9 100644
--- a/rust/tests/helpers.rs
+++ b/rust/tests/helpers.rs
@@ -94,6 +94,7 @@ pub fn check_http_response(
}
}
+#[allow(dead_code)]
pub fn quick_editgroup(conn: &server::DbConn) -> FatcatId {
let editor_id = FatcatId::from_str(TEST_ADMIN_EDITOR_ID).unwrap();
let eg = Editgroup {
@@ -102,7 +103,7 @@ pub fn quick_editgroup(conn: &server::DbConn) -> FatcatId {
editor: None,
changelog_index: None,
submitted: None,
- description: None,
+ description: Some("quick test editgroup".to_string()),
extra: None,
annotations: None,
edits: None,
diff --git a/rust/tests/test_api_server_http.rs b/rust/tests/test_api_server_http.rs
index af19e4f2..0ec2650a 100644
--- a/rust/tests/test_api_server_http.rs
+++ b/rust/tests/test_api_server_http.rs
@@ -999,6 +999,17 @@ fn test_accept_editgroup() {
None,
);
+ helpers::check_http_response(
+ request::post(
+ &format!("http://localhost:9411/v0/editgroup/{}/accept", editgroup_id),
+ headers.clone(),
+ "",
+ &router,
+ ),
+ status::BadRequest,
+ None,
+ );
+
let c: i64 = container_ident::table
.filter(container_ident::is_live.eq(false))
.count()
@@ -1663,3 +1674,142 @@ fn test_create_editgroup() {
None,
);
}
+
+#[test]
+fn test_get_editgroup() {
+ let (headers, router, _conn) = helpers::setup_http();
+
+ helpers::check_http_response(
+ request::get(
+ "http://localhost:9411/v0/editgroup/aaaaaaaaaaaabo53aaaaaaaaae",
+ headers.clone(),
+ &router,
+ ),
+ status::Ok,
+ Some("changelog_index"),
+ );
+
+ helpers::check_http_response(
+ request::get(
+ "http://localhost:9411/v0/editor/aaaaaaaaaaaabkvkaaaaaaaaam/editgroups",
+ headers.clone(),
+ &router,
+ ),
+ status::Ok,
+ Some("user edit"),
+ );
+
+ helpers::check_http_response(
+ request::get(
+ "http://localhost:9411/v0/editgroup/reviewable",
+ headers.clone(),
+ &router,
+ ),
+ status::Ok,
+ Some("edit for submission"),
+ );
+}
+
+#[test]
+fn test_put_editgroup() {
+ let (headers, router, conn) = helpers::setup_http();
+ let editgroup_id = helpers::quick_editgroup(&conn);
+
+ helpers::check_http_response(
+ request::put(
+ &format!(
+ "http://localhost:9411/v0/editgroup/{}?submit=false",
+ editgroup_id
+ ),
+ headers.clone(),
+ &format!(r#"{{"editgroup_id": "{}"}}"#, editgroup_id),
+ &router,
+ ),
+ status::Ok,
+ None,
+ );
+
+ helpers::check_http_response(
+ request::put(
+ &format!(
+ "http://localhost:9411/v0/editgroup/{}?submit=true",
+ editgroup_id
+ ),
+ headers.clone(),
+ &format!(r#"{{"editgroup_id": "{}"}}"#, editgroup_id),
+ &router,
+ ),
+ status::Ok,
+ None,
+ );
+
+ helpers::check_http_response(
+ request::get(
+ &format!("http://localhost:9411/v0/editgroup/reviewable"),
+ headers.clone(),
+ &router,
+ ),
+ status::Ok,
+ Some("quick test editgroup"),
+ );
+}
+
+#[test]
+fn test_editgroup_annotations() {
+ let (headers, router, conn) = helpers::setup_http();
+ let editgroup_id = helpers::quick_editgroup(&conn);
+
+ // pre-existing
+ helpers::check_http_response(
+ request::get(
+ "http://localhost:9411/v0/editgroup/aaaaaaaaaaaabo53aaaaaaaaa4/annotations",
+ headers.clone(),
+ &router,
+ ),
+ status::Ok,
+ Some("love this edit"),
+ );
+
+ helpers::check_http_response(
+ request::post(
+ &format!(
+ "http://localhost:9411/v0/editgroup/{}/annotation",
+ editgroup_id
+ ),
+ headers.clone(),
+ r#"{"comment_markdown": "new special test annotation",
+ "extra": {
+ "bogus-key": "bogus-value"}
+ }"#,
+ &router,
+ ),
+ status::Created,
+ None,
+ );
+
+ helpers::check_http_response(
+ request::get(
+ &format!(
+ "http://localhost:9411/v0/editgroup/{}/annotations",
+ editgroup_id
+ ),
+ headers.clone(),
+ &router,
+ ),
+ status::Ok,
+ Some("special test annotation"),
+ );
+
+ helpers::check_http_response(
+ request::get(
+ &format!(
+ "http://localhost:9411/v0/editor/{}/annotations",
+ helpers::TEST_ADMIN_EDITOR_ID
+ ),
+ headers.clone(),
+ &router,
+ ),
+ status::Ok,
+ Some("special test annotation"),
+ );
+}