diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2018-05-25 18:00:59 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2018-05-25 18:03:40 -0700 |
commit | 0a637859a2e0f0b2015cf567af3bfeab7bbd58da (patch) | |
tree | 993173f7b6b1597ae88eac472066c6bd8696a033 /rust/tests/test_api_server.rs | |
parent | ca5dad8c6b9983c8e417310deac03173f815fa86 (diff) | |
download | fatcat-0a637859a2e0f0b2015cf567af3bfeab7bbd58da.tar.gz fatcat-0a637859a2e0f0b2015cf567af3bfeab7bbd58da.zip |
file_release
Diffstat (limited to 'rust/tests/test_api_server.rs')
-rw-r--r-- | rust/tests/test_api_server.rs | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/rust/tests/test_api_server.rs b/rust/tests/test_api_server.rs index 5d4aaf1d..ac9a8dcc 100644 --- a/rust/tests/test_api_server.rs +++ b/rust/tests/test_api_server.rs @@ -79,13 +79,52 @@ fn test_post_container() { } #[test] +fn test_post_file() { + let server = fatcat::test_server().unwrap(); + let router = fatcat_api::router(server); + let mut headers = Headers::new(); + let mime: Mime = "application/json".parse().unwrap(); + headers.set(ContentType(mime)); + + let response = request::post( + "http://localhost:9411/v0/file", + headers.clone(), + r#"{ }"#, + &router, + ).unwrap(); + let status = response.status; + let body = response::extract_body_to_string(response); + println!("{}", body); + assert_eq!(status, Some(status::Created)); + + let response = request::post( + "http://localhost:9411/v0/file", + headers, + r#"{"size": 76543, + "sha1": "f013d66c7f6817d08b7eb2a93e6d0440c1f3e7f8", + "url": "http://archive.org/asdf.txt", + "releases": [ + "f1f046a3-45c9-4b99-4444-000000000001", + "f1f046a3-45c9-4b99-4444-000000000002" + ] + }"#, + &router, + ).unwrap(); + let status = response.status; + let body = response::extract_body_to_string(response); + println!("{}", body); + assert_eq!(status, Some(status::Created)); + //assert!(body.contains("secret paper")); +} + +#[test] fn test_post_release() { let server = fatcat::test_server().unwrap(); let router = fatcat_api::router(server); let mut headers = Headers::new(); let mime: Mime = "application/json".parse().unwrap(); headers.set(ContentType(mime)); - + let response = request::post( "http://localhost:9411/v0/release", headers.clone(), |