summaryrefslogtreecommitdiffstats
path: root/rust/tests/test_api_server_http.rs
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-12-24 15:17:25 -0800
committerBryan Newbold <bnewbold@robocracy.org>2018-12-24 15:17:25 -0800
commit24ab203a00354f768fc48e0786b21de4afcd9c4a (patch)
tree7c5305dafc110fb58e0ab323ba8b58c1f61914ba /rust/tests/test_api_server_http.rs
parentd7a4e4649e1da2c02ec8472173c79f7c708ce19b (diff)
downloadfatcat-24ab203a00354f768fc48e0786b21de4afcd9c4a.tar.gz
fatcat-24ab203a00354f768fc48e0786b21de4afcd9c4a.zip
implement release_year (and rustfmt)
Diffstat (limited to 'rust/tests/test_api_server_http.rs')
-rw-r--r--rust/tests/test_api_server_http.rs76
1 files changed, 76 insertions, 0 deletions
diff --git a/rust/tests/test_api_server_http.rs b/rust/tests/test_api_server_http.rs
index 714cfc68..d6cdb6d3 100644
--- a/rust/tests/test_api_server_http.rs
+++ b/rust/tests/test_api_server_http.rs
@@ -586,6 +586,7 @@ fn test_post_release() {
r#"{"title": "secret paper",
"release_type": "article-journal",
"release_date": "2000-01-02",
+ "release_year": 2000,
"doi": "10.1234/abcde.781231231239",
"pmid": "54321",
"pmcid": "PMC12345",
@@ -1230,6 +1231,81 @@ fn test_release_dates() {
None,
);
+ // Ok
+ check_http_response(
+ request::post(
+ "http://localhost:9411/v0/release",
+ headers.clone(),
+ r#"{"title": "secret minimal paper",
+ "release_type": "article-journal",
+ "release_year": 2000
+ }"#,
+ &router,
+ ),
+ status::Created,
+ None,
+ );
+
+ // Ok; ISO 8601
+ check_http_response(
+ request::post(
+ "http://localhost:9411/v0/release",
+ headers.clone(),
+ r#"{"title": "secret minimal paper",
+ "release_type": "article-journal",
+ "release_year": -100
+ }"#,
+ &router,
+ ),
+ status::Created,
+ None,
+ );
+ check_http_response(
+ request::post(
+ "http://localhost:9411/v0/release",
+ headers.clone(),
+ r#"{"title": "secret minimal paper",
+ "release_type": "article-journal",
+ "release_year": 0
+ }"#,
+ &router,
+ ),
+ status::Created,
+ None,
+ );
+
+ // Ok
+ check_http_response(
+ request::post(
+ "http://localhost:9411/v0/release",
+ headers.clone(),
+ r#"{"title": "secret minimal paper",
+ "release_type": "article-journal",
+ "release_date": "2000-01-02",
+ "release_year": 2000
+ }"#,
+ &router,
+ ),
+ status::Created,
+ None,
+ );
+
+ // Ok for now, but may be excluded later
+ check_http_response(
+ request::post(
+ "http://localhost:9411/v0/release",
+ headers.clone(),
+ r#"{"title": "secret minimal paper",
+ "release_type": "article-journal",
+ "release_date": "2000-01-02",
+ "release_year": 1999
+ }"#,
+ &router,
+ ),
+ status::Created,
+ None,
+ );
+
// Bad: year/month only
check_http_response(
request::post(