diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2019-05-10 15:17:24 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2019-05-10 15:17:24 -0700 |
commit | 89109a6320b2bcf62f87cd1627ba924385e33473 (patch) | |
tree | af10936f4e812a6a90163ca2bbb3f32a0a64b02f /rust/tests/test_extid.rs | |
parent | 3bc9275cedbf307b53941cad3df9286be6396ab9 (diff) | |
download | fatcat-89109a6320b2bcf62f87cd1627ba924385e33473.tar.gz fatcat-89109a6320b2bcf62f87cd1627ba924385e33473.zip |
add a rust test for extid table UNIQ
Diffstat (limited to 'rust/tests/test_extid.rs')
-rw-r--r-- | rust/tests/test_extid.rs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/rust/tests/test_extid.rs b/rust/tests/test_extid.rs new file mode 100644 index 00000000..f0dc11d1 --- /dev/null +++ b/rust/tests/test_extid.rs @@ -0,0 +1,37 @@ + +use diesel::prelude::*; +use fatcat::database_models::*; +use fatcat::database_schema::*; +use fatcat::server; +use diesel::insert_into; +use std::str::FromStr; +use uuid::Uuid; + +mod helpers; + +#[test] +fn test_extid_uniq() { + // This test ensures that the SQL UNIQ constraint is working + let server = server::create_test_server().unwrap(); + let conn = server.db_pool.get().expect("db_pool error"); + + let resp = insert_into(release_rev_extid::table) + .values(ReleaseExtidRow { + release_rev: Uuid::from_str("00000000-0000-0000-4444-FFF000000002").unwrap(), + extid_type: "arxiv".to_string(), + value: "1905.03769v1".to_string(), + }) + .execute(&conn); + + assert!(resp.is_err()); + + let resp = insert_into(release_rev_extid::table) + .values(ReleaseExtidRow { + release_rev: Uuid::from_str("00000000-0000-0000-4444-FFF000000002").unwrap(), + extid_type: "arxiv_blah".to_string(), + value: "1905.03769v1".to_string(), + }) + .execute(&conn); + + assert!(resp.is_ok()); +} |