aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rust/src/api_helpers.rs13
-rw-r--r--rust/src/api_server.rs88
-rw-r--r--rust/src/api_wrappers.rs8
-rw-r--r--rust/src/database_models.rs50
-rw-r--r--rust/src/database_schema.rs56
-rw-r--r--rust/tests/test_api_server.rs23
-rw-r--r--rust/tests/test_fcid.rs6
7 files changed, 129 insertions, 115 deletions
diff --git a/rust/src/api_helpers.rs b/rust/src/api_helpers.rs
index 1ee08c76..14d3dd5e 100644
--- a/rust/src/api_helpers.rs
+++ b/rust/src/api_helpers.rs
@@ -6,7 +6,7 @@ use diesel::prelude::*;
use errors::*;
use uuid::Uuid;
-pub fn get_or_create_editgroup(editor_id: i64, conn: &PgConnection) -> Result<i64> {
+pub fn get_or_create_editgroup(editor_id: Uuid, conn: &PgConnection) -> Result<Uuid> {
// check for current active
let ed_row: EditorRow = editor::table.find(editor_id).first(conn)?;
if let Some(current) = ed_row.active_editgroup_id {
@@ -25,7 +25,7 @@ pub fn get_or_create_editgroup(editor_id: i64, conn: &PgConnection) -> Result<i6
})
}
-pub fn accept_editgroup(editgroup_id: i64, conn: &PgConnection) -> Result<ChangelogRow> {
+pub fn accept_editgroup(editgroup_id: Uuid, conn: &PgConnection) -> Result<ChangelogRow> {
conn.build_transaction().run(|| {
// check that we haven't accepted already (in changelog)
// NB: could leave this to a UNIQUE constraint
@@ -34,7 +34,10 @@ pub fn accept_editgroup(editgroup_id: i64, conn: &PgConnection) -> Result<Change
.count()
.get_result(conn)?;
if count > 0 {
- bail!("editgroup {} has already been accepted", editgroup_id);
+ bail!(
+ "editgroup {} has already been accepted",
+ editgroup_id.to_string()
+ );
}
// for each entity type...
@@ -69,7 +72,7 @@ pub fn accept_editgroup(editgroup_id: i64, conn: &PgConnection) -> Result<Change
{entity}_ident.id = {entity}_edit.ident_id
AND {entity}_edit.editgroup_id = $1",
entity = entity
- )).bind::<diesel::sql_types::BigInt, _>(editgroup_id)
+ )).bind::<diesel::sql_types::Uuid, _>(editgroup_id)
.execute(conn)?;
}
@@ -79,7 +82,7 @@ pub fn accept_editgroup(editgroup_id: i64, conn: &PgConnection) -> Result<Change
.get_result(conn)?;
// update any editor's active editgroup
- let no_active: Option<i64> = None;
+ let no_active: Option<Uuid> = None;
diesel::update(editor::table)
.filter(editor::active_editgroup_id.eq(editgroup_id))
.set(editor::active_editgroup_id.eq(no_active))
diff --git a/rust/src/api_server.rs b/rust/src/api_server.rs
index b7b19a85..fa64bf7b 100644
--- a/rust/src/api_server.rs
+++ b/rust/src/api_server.rs
@@ -13,7 +13,7 @@ use diesel::{self, insert_into};
use errors::*;
use fatcat_api::models;
use fatcat_api::models::*;
-use uuid;
+use uuid::Uuid;
type DbConn = diesel::r2d2::PooledConnection<diesel::r2d2::ConnectionManager<diesel::PgConnection>>;
@@ -99,7 +99,7 @@ fn container_row2entity(
coden: rev.coden,
state: state,
ident: ident_id,
- revision: Some(rev.id),
+ revision: Some(uuid2fcid(&rev.id)),
redirect: redirect_id,
extra: rev.extra_json,
editgroup_id: None,
@@ -122,7 +122,7 @@ fn creator_row2entity(ident: Option<CreatorIdentRow>, rev: CreatorRevRow) -> Res
orcid: rev.orcid,
state: state,
ident: ident_id,
- revision: Some(rev.id),
+ revision: Some(uuid2fcid(&rev.id)),
redirect: redirect_id,
editgroup_id: None,
extra: rev.extra_json,
@@ -160,7 +160,7 @@ fn file_row2entity(
releases: Some(releases),
state: state,
ident: ident_id,
- revision: Some(rev.id),
+ revision: Some(uuid2fcid(&rev.id)),
redirect: redirect_id,
editgroup_id: None,
extra: rev.extra_json,
@@ -232,7 +232,7 @@ fn release_row2entity(
contribs: Some(contribs),
state: state,
ident: ident_id,
- revision: Some(rev.id),
+ revision: Some(uuid2fcid(&rev.id)),
redirect: redirect_id,
editgroup_id: None,
extra: rev.extra_json,
@@ -252,7 +252,7 @@ fn work_row2entity(ident: Option<WorkIdentRow>, rev: WorkRevRow) -> Result<WorkE
work_type: rev.work_type,
state: state,
ident: ident_id,
- revision: Some(rev.id),
+ revision: Some(uuid2fcid(&rev.id)),
redirect: redirect_id,
editgroup_id: None,
extra: rev.extra_json,
@@ -439,10 +439,10 @@ impl Server {
Some(ref c) => c,
None => conn.unwrap(),
};
- let editor_id = 1; // TODO: auth
- let editgroup_id = match entity.editgroup_id {
+ let editor_id = Uuid::parse_str("00000000-0000-0000-AAAA-000000000001")?; // TODO: auth
+ let editgroup_id: Uuid = match entity.editgroup_id {
None => get_or_create_editgroup(editor_id, &conn)?,
- Some(param) => param as i64,
+ Some(param) => fcid2uuid(&param)?,
};
let edit: ContainerEditRow = diesel::sql_query(
@@ -461,7 +461,7 @@ impl Server {
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(entity.abbrev)
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(entity.coden)
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Json>, _>(entity.extra)
- .bind::<diesel::sql_types::BigInt, _>(editgroup_id)
+ .bind::<diesel::sql_types::Uuid, _>(editgroup_id)
.get_result(conn)?;
edit.to_model()
@@ -481,10 +481,10 @@ impl Server {
Some(ref c) => c,
None => conn.unwrap(),
};
- let editor_id = 1; // TODO: auth
+ let editor_id = Uuid::parse_str("00000000-0000-0000-AAAA-000000000001")?; // TODO: auth
let editgroup_id = match entity.editgroup_id {
None => get_or_create_editgroup(editor_id, &conn).expect("current editgroup"),
- Some(param) => param as i64,
+ Some(param) => fcid2uuid(&param)?,
};
let edit: CreatorEditRow = diesel::sql_query(
@@ -502,7 +502,7 @@ impl Server {
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(entity.surname)
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(entity.orcid)
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Json>, _>(entity.extra)
- .bind::<diesel::sql_types::BigInt, _>(editgroup_id)
+ .bind::<diesel::sql_types::Uuid, _>(editgroup_id)
.get_result(conn)?;
edit.to_model()
@@ -522,10 +522,10 @@ impl Server {
Some(ref c) => c,
None => conn.unwrap(),
};
- let editor_id = 1; // TODO: auth
+ let editor_id = Uuid::parse_str("00000000-0000-0000-AAAA-000000000001")?; // TODO: auth
let editgroup_id = match entity.editgroup_id {
None => get_or_create_editgroup(editor_id, &conn).expect("current editgroup"),
- Some(param) => param as i64,
+ Some(param) => fcid2uuid(&param)?,
};
let edit: FileEditRow =
@@ -546,7 +546,7 @@ impl Server {
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(entity.url)
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(entity.mimetype)
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Json>, _>(entity.extra)
- .bind::<diesel::sql_types::BigInt, _>(editgroup_id)
+ .bind::<diesel::sql_types::Uuid, _>(editgroup_id)
.get_result(conn)?;
let _releases: Option<Vec<FileReleaseRow>> = match entity.releases {
@@ -589,10 +589,10 @@ impl Server {
Some(ref c) => c,
None => conn.unwrap(),
};
- let editor_id = 1; // TODO: auth
+ let editor_id = Uuid::parse_str("00000000-0000-0000-AAAA-000000000001")?; // TODO: auth
let editgroup_id = match entity.editgroup_id {
None => get_or_create_editgroup(editor_id, &conn).expect("current editgroup"),
- Some(param) => param as i64,
+ Some(param) => fcid2uuid(&param)?,
};
let work_id = match entity.work_id {
@@ -605,7 +605,7 @@ impl Server {
revision: None,
redirect: None,
state: None,
- editgroup_id: Some(editgroup_id),
+ editgroup_id: Some(uuid2fcid(&editgroup_id)),
extra: None,
};
let new_entity = self.create_work_handler(work_model, Some(&conn))?;
@@ -613,7 +613,7 @@ impl Server {
}
};
- let container_id: Option<uuid::Uuid> = match entity.container_id {
+ let container_id: Option<Uuid> = match entity.container_id {
Some(id) => Some(fcid2uuid(&id)?),
None => None,
};
@@ -643,7 +643,7 @@ impl Server {
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(entity.publisher)
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(entity.language)
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Json>, _>(entity.extra)
- .bind::<diesel::sql_types::BigInt, _>(editgroup_id)
+ .bind::<diesel::sql_types::Uuid, _>(editgroup_id)
.get_result(conn)?;
let _refs: Option<Vec<ReleaseRefRow>> = match entity.refs {
@@ -722,10 +722,10 @@ impl Server {
None => conn.unwrap(),
};
- let editor_id = 1; // TODO: auth
+ let editor_id = Uuid::parse_str("00000000-0000-0000-AAAA-000000000001")?; // TODO: auth
let editgroup_id = match entity.editgroup_id {
None => get_or_create_editgroup(editor_id, &conn).expect("current editgroup"),
- Some(param) => param as i64,
+ Some(param) => fcid2uuid(&param)?,
};
let edit: WorkEditRow =
@@ -741,15 +741,15 @@ impl Server {
RETURNING *",
).bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(entity.work_type)
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Json>, _>(entity.extra)
- .bind::<diesel::sql_types::BigInt, _>(editgroup_id)
+ .bind::<diesel::sql_types::Uuid, _>(editgroup_id)
.get_result(conn)?;
edit.to_model()
}
- pub fn accept_editgroup_handler(&self, id: i64) -> Result<()> {
+ pub fn accept_editgroup_handler(&self, id: String) -> Result<()> {
let conn = self.db_pool.get().expect("db_pool error");
- accept_editgroup(id as i64, &conn)?;
+ accept_editgroup(fcid2uuid(&id)?, &conn)?;
Ok(())
}
@@ -758,7 +758,7 @@ impl Server {
let row: EditgroupRow = insert_into(editgroup::table)
.values((
- editgroup::editor_id.eq(entity.editor_id as i64),
+ editgroup::editor_id.eq(fcid2uuid(&entity.editor_id)?),
editgroup::description.eq(entity.description),
editgroup::extra_json.eq(entity.extra),
))
@@ -766,18 +766,19 @@ impl Server {
.expect("error creating edit group");
Ok(Editgroup {
- id: Some(row.id),
- editor_id: row.editor_id,
+ id: Some(uuid2fcid(&row.id)),
+ editor_id: uuid2fcid(&row.editor_id),
description: row.description,
edits: None,
extra: row.extra_json,
})
}
- pub fn get_editgroup_handler(&self, id: i64) -> Result<Editgroup> {
+ pub fn get_editgroup_handler(&self, id: String) -> Result<Editgroup> {
let conn = self.db_pool.get().expect("db_pool error");
- let row: EditgroupRow = editgroup::table.find(id as i64).first(&conn)?;
+ let id = fcid2uuid(&id)?;
+ let row: EditgroupRow = editgroup::table.find(id).first(&conn)?;
let edits = EditgroupEdits {
containers: Some(
@@ -823,8 +824,8 @@ impl Server {
};
let eg = Editgroup {
- id: Some(row.id),
- editor_id: row.editor_id,
+ id: Some(uuid2fcid(&row.id)),
+ editor_id: uuid2fcid(&row.editor_id),
description: row.description,
edits: Some(edits),
extra: row.extra_json,
@@ -832,26 +833,25 @@ impl Server {
Ok(eg)
}
- pub fn get_editor_handler(&self, username: String) -> Result<Editor> {
+ pub fn get_editor_handler(&self, id: String) -> Result<Editor> {
let conn = self.db_pool.get().expect("db_pool error");
- let row: EditorRow = editor::table
- .filter(editor::username.eq(&username))
- .first(&conn)?;
+ let id = fcid2uuid(&id)?;
+ let row: EditorRow = editor::table.find(id).first(&conn)?;
let ed = Editor {
+ id: Some(uuid2fcid(&row.id)),
username: row.username,
};
Ok(ed)
}
- pub fn editor_changelog_get_handler(&self, username: String) -> Result<Vec<ChangelogEntry>> {
+ pub fn editor_changelog_get_handler(&self, id: String) -> Result<Vec<ChangelogEntry>> {
let conn = self.db_pool.get().expect("db_pool error");
+ let id = fcid2uuid(&id)?;
// TODO: single query
- let editor: EditorRow = editor::table
- .filter(editor::username.eq(username))
- .first(&conn)?;
+ let editor: EditorRow = editor::table.find(id).first(&conn)?;
let changes: Vec<(ChangelogRow, EditgroupRow)> = changelog::table
.inner_join(editgroup::table)
.filter(editgroup::editor_id.eq(editor.id))
@@ -862,7 +862,7 @@ impl Server {
.map(|(cl_row, eg_row)| ChangelogEntry {
index: cl_row.id,
editgroup: Some(eg_row.to_model_partial()),
- editgroup_id: cl_row.editgroup_id,
+ editgroup_id: uuid2fcid(&cl_row.editgroup_id),
timestamp: chrono::DateTime::from_utc(cl_row.timestamp, chrono::Utc),
})
.collect();
@@ -884,7 +884,7 @@ impl Server {
.map(|(cl_row, eg_row)| ChangelogEntry {
index: cl_row.id,
editgroup: Some(eg_row.to_model_partial()),
- editgroup_id: cl_row.editgroup_id,
+ editgroup_id: uuid2fcid(&cl_row.editgroup_id),
timestamp: chrono::DateTime::from_utc(cl_row.timestamp, chrono::Utc),
})
.collect();
@@ -895,7 +895,7 @@ impl Server {
let conn = self.db_pool.get().expect("db_pool error");
let cl_row: ChangelogRow = changelog::table.find(id).first(&conn)?;
- let editgroup = self.get_editgroup_handler(cl_row.editgroup_id)?;
+ let editgroup = self.get_editgroup_handler(uuid2fcid(&cl_row.editgroup_id))?;
let mut entry = cl_row.to_model();
entry.editgroup = Some(editgroup);
diff --git a/rust/src/api_wrappers.rs b/rust/src/api_wrappers.rs
index bc1e61ef..4d5c6ddf 100644
--- a/rust/src/api_wrappers.rs
+++ b/rust/src/api_wrappers.rs
@@ -268,10 +268,10 @@ impl Api for Server {
fn accept_editgroup(
&self,
- id: i64,
+ id: String,
_context: &Context,
) -> Box<Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send> {
- let ret = match self.accept_editgroup_handler(id) {
+ let ret = match self.accept_editgroup_handler(id.clone()) {
Ok(()) => AcceptEditgroupResponse::MergedSuccessfully(Success {
message: "horray!".to_string(),
}),
@@ -289,10 +289,10 @@ impl Api for Server {
fn get_editgroup(
&self,
- id: i64,
+ id: String,
_context: &Context,
) -> Box<Future<Item = GetEditgroupResponse, Error = ApiError> + Send> {
- let ret = match self.get_editgroup_handler(id) {
+ let ret = match self.get_editgroup_handler(id.clone()) {
Ok(entity) =>
GetEditgroupResponse::FoundEntity(entity),
Err(Error(ErrorKind::Diesel(::diesel::result::Error::NotFound), _)) =>
diff --git a/rust/src/database_models.rs b/rust/src/database_models.rs
index 15dffad0..79ff45fe 100644
--- a/rust/src/database_models.rs
+++ b/rust/src/database_models.rs
@@ -11,8 +11,8 @@ use uuid::Uuid;
pub enum EntityState {
WorkInProgress,
- Active(i64),
- Redirect(Uuid, i64),
+ Active(Uuid),
+ Redirect(Uuid, Uuid),
Deleted,
}
@@ -42,9 +42,9 @@ macro_rules! entity_structs {
#[table_name = $edit_table]
pub struct $edit_struct {
pub id: i64,
- pub editgroup_id: i64,
+ pub editgroup_id: Uuid,
pub ident_id: Uuid,
- pub rev_id: Option<i64>,
+ pub rev_id: Option<Uuid>,
pub redirect_id: Option<Uuid>,
pub extra_json: Option<serde_json::Value>,
}
@@ -53,8 +53,8 @@ macro_rules! entity_structs {
/// Go from a row (SQL model) to an API model
fn to_model(self) -> Result<EntityEdit> {
Ok(EntityEdit {
- editgroup_id: self.editgroup_id,
- revision: self.rev_id,
+ editgroup_id: uuid2fcid(&self.editgroup_id),
+ revision: self.rev_id.map(|v| uuid2fcid(&v)),
redirect_ident: self.redirect_id.map(|v| uuid2fcid(&v)),
ident: uuid2fcid(&self.ident_id),
edit_id: self.id,
@@ -68,7 +68,7 @@ macro_rules! entity_structs {
pub struct $ident_struct {
pub id: Uuid,
pub is_live: bool,
- pub rev_id: Option<i64>,
+ pub rev_id: Option<Uuid>,
pub redirect_id: Option<Uuid>,
}
@@ -91,7 +91,7 @@ macro_rules! entity_structs {
#[derive(Debug, Queryable, Identifiable, Associations, AsChangeset)]
#[table_name = "container_rev"]
pub struct ContainerRevRow {
- pub id: i64,
+ pub id: Uuid,
pub extra_json: Option<serde_json::Value>,
pub name: String,
pub publisher: Option<String>,
@@ -110,7 +110,7 @@ entity_structs!(
#[derive(Debug, Queryable, Identifiable, Associations, AsChangeset)]
#[table_name = "creator_rev"]
pub struct CreatorRevRow {
- pub id: i64,
+ pub id: Uuid,
pub extra_json: Option<serde_json::Value>,
pub display_name: String,
pub given_name: Option<String>,
@@ -128,7 +128,7 @@ entity_structs!(
#[derive(Debug, Queryable, Identifiable, Associations, AsChangeset)]
#[table_name = "file_rev"]
pub struct FileRevRow {
- pub id: i64,
+ pub id: Uuid,
pub extra_json: Option<serde_json::Value>,
pub size: Option<i64>,
pub sha1: Option<String>,
@@ -143,7 +143,7 @@ entity_structs!("file_edit", FileEditRow, "file_ident", FileIdentRow);
#[derive(Debug, Queryable, Identifiable, Associations, AsChangeset)]
#[table_name = "release_rev"]
pub struct ReleaseRevRow {
- pub id: i64,
+ pub id: Uuid,
pub extra_json: Option<serde_json::Value>,
pub work_ident_id: Uuid,
pub container_ident_id: Option<Uuid>,
@@ -170,7 +170,7 @@ entity_structs!(
#[derive(Debug, Queryable, Identifiable, Associations, AsChangeset)]
#[table_name = "work_rev"]
pub struct WorkRevRow {
- pub id: i64,
+ pub id: Uuid,
pub extra_json: Option<serde_json::Value>,
pub work_type: Option<String>,
pub primary_release_id: Option<Uuid>,
@@ -182,7 +182,7 @@ entity_structs!("work_edit", WorkEditRow, "work_ident", WorkIdentRow);
#[table_name = "release_contrib"]
pub struct ReleaseContribRow {
pub id: i64,
- pub release_rev: i64,
+ pub release_rev: Uuid,
pub creator_ident_id: Option<Uuid>,
pub role: Option<String>,
pub index: Option<i64>,
@@ -192,7 +192,7 @@ pub struct ReleaseContribRow {
#[derive(Debug, Insertable)]
#[table_name = "release_contrib"]
pub struct ReleaseContribNewRow {
- pub release_rev: i64,
+ pub release_rev: Uuid,
pub creator_ident_id: Option<Uuid>,
pub role: Option<String>,
pub index: Option<i64>,
@@ -203,7 +203,7 @@ pub struct ReleaseContribNewRow {
#[table_name = "release_ref"]
pub struct ReleaseRefRow {
pub id: i64,
- pub release_rev: i64,
+ pub release_rev: Uuid,
pub target_release_ident_id: Option<Uuid>,
pub index: Option<i64>,
pub key: Option<String>,
@@ -217,7 +217,7 @@ pub struct ReleaseRefRow {
#[derive(Debug, Insertable, AsChangeset)]
#[table_name = "release_ref"]
pub struct ReleaseRefNewRow {
- pub release_rev: i64,
+ pub release_rev: Uuid,
pub target_release_ident_id: Option<Uuid>,
pub index: Option<i64>,
pub key: Option<String>,
@@ -231,16 +231,16 @@ pub struct ReleaseRefNewRow {
#[derive(Debug, Queryable, Insertable, Associations, AsChangeset)]
#[table_name = "file_release"]
pub struct FileReleaseRow {
- pub file_rev: i64,
+ pub file_rev: Uuid,
pub target_release_ident_id: Uuid,
}
#[derive(Debug, Queryable, Identifiable, Associations, AsChangeset)]
#[table_name = "editgroup"]
pub struct EditgroupRow {
- pub id: i64,
+ pub id: Uuid,
pub extra_json: Option<serde_json::Value>,
- pub editor_id: i64,
+ pub editor_id: Uuid,
pub description: Option<String>,
}
@@ -249,8 +249,8 @@ impl EditgroupRow {
/// eg, entity history queries (where we already have the entity edit we want)
pub fn to_model_partial(self) -> Editgroup {
Editgroup {
- id: Some(self.id),
- editor_id: self.editor_id,
+ id: Some(uuid2fcid(&self.id)),
+ editor_id: uuid2fcid(&self.editor_id),
description: self.description,
extra: self.extra_json,
edits: None,
@@ -261,17 +261,17 @@ impl EditgroupRow {
#[derive(Debug, Queryable, Identifiable, Associations, AsChangeset)]
#[table_name = "editor"]
pub struct EditorRow {
- pub id: i64,
+ pub id: Uuid,
pub username: String,
pub is_admin: bool,
- pub active_editgroup_id: Option<i64>,
+ pub active_editgroup_id: Option<Uuid>,
}
#[derive(Debug, Queryable, Identifiable, Associations, AsChangeset)]
#[table_name = "changelog"]
pub struct ChangelogRow {
pub id: i64,
- pub editgroup_id: i64,
+ pub editgroup_id: Uuid,
pub timestamp: chrono::NaiveDateTime,
}
@@ -279,7 +279,7 @@ impl ChangelogRow {
pub fn to_model(self) -> ChangelogEntry {
ChangelogEntry {
index: self.id,
- editgroup_id: self.editgroup_id,
+ editgroup_id: uuid2fcid(&self.editgroup_id),
editgroup: None,
timestamp: chrono::DateTime::from_utc(self.timestamp, chrono::Utc),
}
diff --git a/rust/src/database_schema.rs b/rust/src/database_schema.rs
index 34ca16c4..d99fdd3f 100644
--- a/rust/src/database_schema.rs
+++ b/rust/src/database_schema.rs
@@ -1,7 +1,7 @@
table! {
changelog (id) {
id -> Int8,
- editgroup_id -> Int8,
+ editgroup_id -> Uuid,
timestamp -> Timestamp,
}
}
@@ -9,9 +9,9 @@ table! {
table! {
container_edit (id) {
id -> Int8,
- editgroup_id -> Int8,
+ editgroup_id -> Uuid,
ident_id -> Uuid,
- rev_id -> Nullable<Int8>,
+ rev_id -> Nullable<Uuid>,
redirect_id -> Nullable<Uuid>,
extra_json -> Nullable<Json>,
}
@@ -21,14 +21,14 @@ table! {
container_ident (id) {
id -> Uuid,
is_live -> Bool,
- rev_id -> Nullable<Int8>,
+ rev_id -> Nullable<Uuid>,
redirect_id -> Nullable<Uuid>,
}
}
table! {
container_rev (id) {
- id -> Int8,
+ id -> Uuid,
extra_json -> Nullable<Json>,
name -> Text,
publisher -> Nullable<Text>,
@@ -41,9 +41,9 @@ table! {
table! {
creator_edit (id) {
id -> Int8,
- editgroup_id -> Int8,
+ editgroup_id -> Uuid,
ident_id -> Uuid,
- rev_id -> Nullable<Int8>,
+ rev_id -> Nullable<Uuid>,
redirect_id -> Nullable<Uuid>,
extra_json -> Nullable<Json>,
}
@@ -53,14 +53,14 @@ table! {
creator_ident (id) {
id -> Uuid,
is_live -> Bool,
- rev_id -> Nullable<Int8>,
+ rev_id -> Nullable<Uuid>,
redirect_id -> Nullable<Uuid>,
}
}
table! {
creator_rev (id) {
- id -> Int8,
+ id -> Uuid,
extra_json -> Nullable<Json>,
display_name -> Text,
given_name -> Nullable<Text>,
@@ -71,28 +71,28 @@ table! {
table! {
editgroup (id) {
- id -> Int8,
+ id -> Uuid,
extra_json -> Nullable<Json>,
- editor_id -> Int8,
+ editor_id -> Uuid,
description -> Nullable<Text>,
}
}
table! {
editor (id) {
- id -> Int8,
+ id -> Uuid,
username -> Text,
is_admin -> Bool,
- active_editgroup_id -> Nullable<Int8>,
+ active_editgroup_id -> Nullable<Uuid>,
}
}
table! {
file_edit (id) {
id -> Int8,
- editgroup_id -> Int8,
+ editgroup_id -> Uuid,
ident_id -> Uuid,
- rev_id -> Nullable<Int8>,
+ rev_id -> Nullable<Uuid>,
redirect_id -> Nullable<Uuid>,
extra_json -> Nullable<Json>,
}
@@ -102,21 +102,21 @@ table! {
file_ident (id) {
id -> Uuid,
is_live -> Bool,
- rev_id -> Nullable<Int8>,
+ rev_id -> Nullable<Uuid>,
redirect_id -> Nullable<Uuid>,
}
}
table! {
file_release (file_rev, target_release_ident_id) {
- file_rev -> Int8,
+ file_rev -> Uuid,
target_release_ident_id -> Uuid,
}
}
table! {
file_rev (id) {
- id -> Int8,
+ id -> Uuid,
extra_json -> Nullable<Json>,
size -> Nullable<Int8>,
sha1 -> Nullable<Text>,
@@ -130,7 +130,7 @@ table! {
table! {
release_contrib (id) {
id -> Int8,
- release_rev -> Int8,
+ release_rev -> Uuid,
creator_ident_id -> Nullable<Uuid>,
role -> Nullable<Text>,
index -> Nullable<Int8>,
@@ -141,9 +141,9 @@ table! {
table! {
release_edit (id) {
id -> Int8,
- editgroup_id -> Int8,
+ editgroup_id -> Uuid,
ident_id -> Uuid,
- rev_id -> Nullable<Int8>,
+ rev_id -> Nullable<Uuid>,
redirect_id -> Nullable<Uuid>,
extra_json -> Nullable<Json>,
}
@@ -153,7 +153,7 @@ table! {
release_ident (id) {
id -> Uuid,
is_live -> Bool,
- rev_id -> Nullable<Int8>,
+ rev_id -> Nullable<Uuid>,
redirect_id -> Nullable<Uuid>,
}
}
@@ -161,7 +161,7 @@ table! {
table! {
release_ref (id) {
id -> Int8,
- release_rev -> Int8,
+ release_rev -> Uuid,
target_release_ident_id -> Nullable<Uuid>,
index -> Nullable<Int8>,
key -> Nullable<Text>,
@@ -175,7 +175,7 @@ table! {
table! {
release_rev (id) {
- id -> Int8,
+ id -> Uuid,
extra_json -> Nullable<Json>,
work_ident_id -> Uuid,
container_ident_id -> Nullable<Uuid>,
@@ -196,9 +196,9 @@ table! {
table! {
work_edit (id) {
id -> Int8,
- editgroup_id -> Int8,
+ editgroup_id -> Uuid,
ident_id -> Uuid,
- rev_id -> Nullable<Int8>,
+ rev_id -> Nullable<Uuid>,
redirect_id -> Nullable<Uuid>,
extra_json -> Nullable<Json>,
}
@@ -208,14 +208,14 @@ table! {
work_ident (id) {
id -> Uuid,
is_live -> Bool,
- rev_id -> Nullable<Int8>,
+ rev_id -> Nullable<Uuid>,
redirect_id -> Nullable<Uuid>,
}
}
table! {
work_rev (id) {
- id -> Int8,
+ id -> Uuid,
extra_json -> Nullable<Json>,
work_type -> Nullable<Text>,
primary_release_id -> Nullable<Uuid>,
diff --git a/rust/tests/test_api_server.rs b/rust/tests/test_api_server.rs
index e7ac9585..056c6a0e 100644
--- a/rust/tests/test_api_server.rs
+++ b/rust/tests/test_api_server.rs
@@ -3,6 +3,7 @@ extern crate fatcat;
extern crate fatcat_api;
extern crate iron;
extern crate iron_test;
+extern crate uuid;
use diesel::prelude::*;
use fatcat::api_helpers::*;
@@ -11,6 +12,7 @@ use iron::headers::ContentType;
use iron::mime::Mime;
use iron::{status, Headers};
use iron_test::{request, response};
+use uuid::Uuid;
fn setup() -> (
Headers,
@@ -416,7 +418,8 @@ fn test_post_work() {
fn test_accept_editgroup() {
let (headers, router, conn) = setup();
- let editgroup_id = get_or_create_editgroup(1, &conn).unwrap();
+ let editor_id = Uuid::parse_str("00000000-0000-0000-AAAA-000000000001").unwrap();
+ let editgroup_id = get_or_create_editgroup(editor_id, &conn).unwrap();
let c: i64 = container_ident::table
.filter(container_ident::is_live.eq(false))
@@ -436,8 +439,8 @@ fn test_accept_editgroup() {
"http://localhost:9411/v0/container",
headers.clone(),
&format!(
- "{{\"name\": \"test journal 1\", \"editgroup_id\": {}}}",
- editgroup_id
+ "{{\"name\": \"test journal 1\", \"editgroup_id\": \"{}\"}}",
+ uuid2fcid(&editgroup_id)
),
&router,
),
@@ -449,8 +452,8 @@ fn test_accept_editgroup() {
"http://localhost:9411/v0/container",
headers.clone(),
&format!(
- "{{\"name\": \"test journal 2\", \"editgroup_id\": {}}}",
- editgroup_id
+ "{{\"name\": \"test journal 2\", \"editgroup_id\": \"{}\"}}",
+ uuid2fcid(&editgroup_id)
),
&router,
),
@@ -467,7 +470,10 @@ fn test_accept_editgroup() {
check_response(
request::get(
- &format!("http://localhost:9411/v0/editgroup/{}", editgroup_id),
+ &format!(
+ "http://localhost:9411/v0/editgroup/{}",
+ uuid2fcid(&editgroup_id)
+ ),
headers.clone(),
&router,
),
@@ -477,7 +483,10 @@ fn test_accept_editgroup() {
check_response(
request::post(
- &format!("http://localhost:9411/v0/editgroup/{}/accept", editgroup_id),
+ &format!(
+ "http://localhost:9411/v0/editgroup/{}/accept",
+ uuid2fcid(&editgroup_id)
+ ),
headers.clone(),
"",
&router,
diff --git a/rust/tests/test_fcid.rs b/rust/tests/test_fcid.rs
index befca435..4feaef5d 100644
--- a/rust/tests/test_fcid.rs
+++ b/rust/tests/test_fcid.rs
@@ -14,8 +14,10 @@ fn test_fcid_conversions() {
assert_eq!(test_uuid, fcid2uuid(&test_fcid.to_uppercase()).unwrap());
assert_eq!(test_uuid, fcid2uuid(&uuid2fcid(&test_uuid)).unwrap());
- assert_eq!(Uuid::parse_str("10842108-4210-8421-0842-108421084210").unwrap(),
- fcid2uuid("ccccccccccccccccccccccccca").unwrap());
+ assert_eq!(
+ Uuid::parse_str("10842108-4210-8421-0842-108421084210").unwrap(),
+ fcid2uuid("ccccccccccccccccccccccccca").unwrap()
+ );
assert_eq!(false, fcid2uuid("asdf").is_ok());
assert_eq!(false, fcid2uuid("q3nouwy3nnbsvo3h5klx").is_ok());