Commit f0cd8c0b authored by MrMan's avatar MrMan

Fix up tests

parent e594ffdc
Pipeline #47893608 failed with stage
in 2 minutes and 49 seconds
......@@ -4,7 +4,7 @@ WORKDIR /usr/src/postmgr
COPY . .
# Install postfix
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y ca-certificates install make postfix \
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install ca-certificates make postfix \
rsyslog telnet dovecot-imapd dovecot-pop3d
RUN ln -s /usr/sbin/postfix /usr/bin/postfix
......
......@@ -105,9 +105,11 @@ mod tests {
use models::{DBEntity, ModelWithUUID, PaginationOptions};
const TEST_USER_EMAIL: &'static str = "[email protected]";
const TEST_USER_DOMAIN: &'static str = "localhost";
const TEST_USER_PASSWORD: &'static str = "test";
const ADMIN_USER_EMAIL: &'static str = "[email protected]";
const ADMIN_USER_DOMAIN: &'static str = "localhost";
const ADMIN_USER_PASSWORD: &'static str = "admin";
#[test]
......@@ -115,7 +117,11 @@ mod tests {
let mut db = SQLiteDB::new(SQLiteDBCfg::in_memory());
let _ = db.connect();
let model = MailboxUser::new(String::from(TEST_USER_EMAIL), String::from(TEST_USER_PASSWORD));
let model = MailboxUser::new(
String::from(TEST_USER_EMAIL),
String::from(TEST_USER_DOMAIN),
String::from(TEST_USER_PASSWORD)
);
let entity = ModelWithUUID::from_model(model);
let create_result = entity.insert(&db);
......@@ -127,7 +133,11 @@ mod tests {
let mut db = SQLiteDB::new(SQLiteDBCfg::in_memory());
let _ = db.connect();
let model = MailboxUser::new(String::from(TEST_USER_EMAIL), String::from(TEST_USER_PASSWORD));
let model = MailboxUser::new(
String::from(TEST_USER_EMAIL),
String::from(TEST_USER_DOMAIN),
String::from(TEST_USER_PASSWORD)
);
let entity = ModelWithUUID::from_model(model);
let create_result = entity.insert(&db);
......@@ -146,7 +156,11 @@ mod tests {
let mut db = SQLiteDB::new(SQLiteDBCfg::in_memory());
let _ = db.connect();
let model = MailboxUser::new(String::from(TEST_USER_EMAIL), String::from(TEST_USER_PASSWORD));
let model = MailboxUser::new(
String::from(TEST_USER_EMAIL),
String::from(TEST_USER_DOMAIN),
String::from(TEST_USER_PASSWORD)
);
let entity = ModelWithUUID::from_model(model);
// create the user
......@@ -168,7 +182,11 @@ mod tests {
let mut db = SQLiteDB::new(SQLiteDBCfg::in_memory());
let _ = db.connect();
let model = MailboxUser::new(String::from(TEST_USER_EMAIL), String::from(TEST_USER_PASSWORD));
let model = MailboxUser::new(
String::from(TEST_USER_EMAIL),
String::from(TEST_USER_DOMAIN),
String::from(TEST_USER_PASSWORD)
);
let entity = ModelWithUUID::from_model(model);
// create the user
......@@ -191,10 +209,19 @@ mod tests {
let mut db = SQLiteDB::new(SQLiteDBCfg::in_memory());
let _ = db.connect();
let test_model = MailboxUser::new(String::from(TEST_USER_EMAIL), String::from(TEST_USER_PASSWORD));
let test_model = MailboxUser::new(
String::from(TEST_USER_EMAIL),
String::from(TEST_USER_DOMAIN),
String::from(TEST_USER_PASSWORD)
);
let test_entity = ModelWithUUID::from_model(test_model);
let admin_model = MailboxUser::new(String::from(ADMIN_USER_EMAIL), String::from(ADMIN_USER_PASSWORD));
let admin_model = MailboxUser::new(
String::from(ADMIN_USER_EMAIL),
String::from(ADMIN_USER_DOMAIN),
String::from(ADMIN_USER_PASSWORD),
);
let admin_entity = ModelWithUUID::from_model(admin_model);
// create the user
......@@ -219,7 +246,11 @@ mod tests {
let _ = db.connect();
// create the user
let model = MailboxUser::new(String::from(TEST_USER_EMAIL), String::from(TEST_USER_PASSWORD));
let model = MailboxUser::new(
String::from(TEST_USER_EMAIL),
String::from(TEST_USER_DOMAIN),
String::from(TEST_USER_PASSWORD)
);
let entity = ModelWithUUID::from_model(model);
let _ = entity.insert(&db).expect("test entity create failed");
......
......@@ -15,9 +15,9 @@ CREATE TABLE mailbox_users (
username TEXT NOT NULL,
domain TEXT NOT NULL,
password TEXT NOT NULL,
quota_bytes INTEGER DEFAULT 0,
quota_gb INTEGER DEFAULT 0,
CONSTRAINT quota_gt_zero CHECK (quota_bytes >= 0)
CONSTRAINT quota_gt_zero CHECK (quota_gb >= 0)
);
CREATE UNIQUE INDEX mailbox_users_username_domain_idx ON users(username, domain);
......
......@@ -3,6 +3,7 @@ use common::postmgr::models::user::MailboxUser;
pub fn test_user() -> MailboxUser {
MailboxUser {
username: String::from("test"),
domain: String::from("localhost"),
password: String::from("test"),
quota_gb: 5
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment