Fix server tests
This commit is contained in:
parent
8e07e338a6
commit
39760b5956
@ -4,7 +4,6 @@ const wsUrl = () => `${ getProtocol() }//${ getWsHostName() }:${ process.env.JIR
|
|||||||
|
|
||||||
import("/jirs.js").then(async module => {
|
import("/jirs.js").then(async module => {
|
||||||
window.module = module;
|
window.module = module;
|
||||||
console.log(module)
|
|
||||||
await module.default();
|
await module.default();
|
||||||
const host_url = `${ location.protocol }//${ process.env.JIRS_SERVER_BIND }:${ process.env.JIRS_SERVER_PORT }`;
|
const host_url = `${ location.protocol }//${ process.env.JIRS_SERVER_BIND }:${ process.env.JIRS_SERVER_PORT }`;
|
||||||
module.render(host_url, wsUrl());
|
module.render(host_url, wsUrl());
|
||||||
|
@ -303,9 +303,10 @@ impl Handler<ProfileUpdate> for DbExecutor {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::db::build_pool;
|
use crate::db::build_pool;
|
||||||
use crate::models::CreateProjectForm;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use diesel::connection::TransactionManager;
|
||||||
|
use jirs_data::{Project, ProjectCategory};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn check_collision() {
|
fn check_collision() {
|
||||||
@ -316,23 +317,31 @@ mod tests {
|
|||||||
let pool = build_pool();
|
let pool = build_pool();
|
||||||
let conn = &pool.get().unwrap();
|
let conn = &pool.get().unwrap();
|
||||||
|
|
||||||
|
let tm = conn.transaction_manager();
|
||||||
|
|
||||||
|
tm.begin_transaction(conn).unwrap();
|
||||||
|
|
||||||
diesel::delete(user_projects).execute(conn).unwrap();
|
diesel::delete(user_projects).execute(conn).unwrap();
|
||||||
diesel::delete(users).execute(conn).unwrap();
|
diesel::delete(users).execute(conn).unwrap();
|
||||||
diesel::delete(projects).execute(conn).unwrap();
|
diesel::delete(projects).execute(conn).unwrap();
|
||||||
|
|
||||||
let project_form = CreateProjectForm {
|
let project: Project = {
|
||||||
name: "baz".to_string(),
|
use crate::schema::projects::dsl::*;
|
||||||
url: "/uz".to_string(),
|
|
||||||
description: "None".to_string(),
|
diesel::insert_into(projects)
|
||||||
category: Default::default(),
|
.values((
|
||||||
|
name.eq("baz".to_string()),
|
||||||
|
url.eq("/uz".to_string()),
|
||||||
|
description.eq("None".to_string()),
|
||||||
|
category.eq(ProjectCategory::Software),
|
||||||
|
))
|
||||||
|
.get_result::<Project>(conn)
|
||||||
|
.unwrap()
|
||||||
};
|
};
|
||||||
let project: Project = diesel::insert_into(projects)
|
|
||||||
.values(project_form)
|
|
||||||
.get_result(conn)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let user: User = {
|
let user: User = {
|
||||||
use crate::schema::users::dsl::*;
|
use crate::schema::users::dsl::*;
|
||||||
|
|
||||||
diesel::insert_into(users)
|
diesel::insert_into(users)
|
||||||
.values((
|
.values((
|
||||||
name.eq("Foo".to_string()),
|
name.eq("Foo".to_string()),
|
||||||
@ -354,8 +363,14 @@ mod tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_eq!(count_matching_users("Foo", "bar@example.com", conn), 1);
|
let res1 = count_matching_users("Foo", "bar@example.com", conn);
|
||||||
assert_eq!(count_matching_users("Bar", "foo@example.com", conn), 1);
|
let res2 = count_matching_users("Bar", "foo@example.com", conn);
|
||||||
assert_eq!(count_matching_users("Foo", "foo@example.com", conn), 1);
|
let res3 = count_matching_users("Foo", "foo@example.com", conn);
|
||||||
|
|
||||||
|
tm.rollback_transaction(conn).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(res1, 1);
|
||||||
|
assert_eq!(res2, 1);
|
||||||
|
assert_eq!(res3, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user