diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2018-05-25 18:39:51 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2018-05-25 18:39:51 -0700 |
commit | f8d9d4f92bcb491d54360e335745056be0de19e2 (patch) | |
tree | 32972efe906fc2c873c1fd521e3688462c2dfd72 /rust | |
parent | 6da398b730bbc269769066a8181f07d84f954f44 (diff) | |
download | fatcat-f8d9d4f92bcb491d54360e335745056be0de19e2.tar.gz fatcat-f8d9d4f92bcb491d54360e335745056be0de19e2.zip |
more POST tests
Diffstat (limited to 'rust')
-rw-r--r-- | rust/tests/test_api_server.rs | 90 |
1 files changed, 89 insertions, 1 deletions
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,11 +42,21 @@ 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", headers.clone(), &router, @@ -57,6 +67,41 @@ fn test_basics() { 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", headers.clone(), &router, @@ -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] @@ -108,6 +163,22 @@ fn test_post_container() { } #[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(); @@ -196,6 +267,23 @@ fn test_post_release() { } #[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(); |