From f8d9d4f92bcb491d54360e335745056be0de19e2 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Fri, 25 May 2018 18:39:51 -0700 Subject: more POST tests --- rust/tests/test_api_server.rs | 90 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 89 insertions(+), 1 deletion(-) (limited to 'rust') diff --git a/rust/tests/test_api_server.rs b/rust/tests/test_api_server.rs index ccc5c371..1ffbee90 100644 --- a/rust/tests/test_api_server.rs +++ b/rust/tests/test_api_server.rs @@ -42,9 +42,19 @@ fn check_response( } #[test] -fn test_basics() { +fn test_entity_gets() { let (headers, router, _conn) = setup(); + check_response( + request::get( + "http://localhost:9411/v0/container/f1f046a3-45c9-4b99-cccc-000000000002", + headers.clone(), + &router, + ), + status::Ok, + Some("MySpace"), + ); + check_response( request::get( "http://localhost:9411/v0/creator/f1f046a3-45c9-4b99-adce-000000000001", @@ -55,6 +65,41 @@ fn test_basics() { Some("Grace Hopper"), ); + check_response( + request::get( + "http://localhost:9411/v0/file/f1f046a3-45c9-4b99-ffff-000000000002", + headers.clone(), + &router, + ), + status::Ok, + Some("archive.org"), + ); + + check_response( + request::get( + "http://localhost:9411/v0/work/f1f046a3-45c9-4b99-3333-000000000002", + headers.clone(), + &router, + ), + status::Ok, + None, + ); + + check_response( + request::get( + "http://localhost:9411/v0/release/f1f046a3-45c9-4b99-4444-000000000002", + headers.clone(), + &router, + ), + status::Ok, + Some("bigger example"), + ); +} + +#[test] +fn test_entity_404() { + let (headers, router, _conn) = setup(); + check_response( request::get( "http://localhost:9411/v0/creator/f1f046a3-45c9-4b99-adce-999999999999", @@ -89,6 +134,16 @@ fn test_lookups() { status::Ok, Some("Christine Moran"), ); + + check_response( + request::get( + "http://localhost:9411/v0/file/lookup?sha1=7d97e98f8af710c7e7fe703abc8f639e0ee507c4", + headers.clone(), + &router, + ), + status::Ok, + Some("robots.txt"), + ); } #[test] @@ -107,6 +162,22 @@ fn test_post_container() { ); // TODO: "test journal" } +#[test] +fn test_post_creator() { + let (headers, router, _conn) = setup(); + + check_response( + request::post( + "http://localhost:9411/v0/creator", + headers, + r#"{"name": "some person"}"#, + &router, + ), + status::Created, + None, + ); +} + #[test] fn test_post_file() { let (headers, router, _conn) = setup(); @@ -195,6 +266,23 @@ fn test_post_release() { ); // TODO: "secret paper" } +#[test] +fn test_post_work() { + let (headers, router, _conn) = setup(); + + check_response( + request::post( + "http://localhost:9411/v0/work", + headers.clone(), + // TODO: target_work_id + r#"{"work_type": "journal-article"}"#, + &router, + ), + status::Created, + None, + ); +} + #[test] fn test_accept_editgroup() { let (headers, router, conn) = setup(); -- cgit v1.2.3