tsk-271: Test refactor
This commit is contained in:
1 file changed
+15
-15
+15
-15
@@ -137,20 +137,11 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn token_fields() -> (String, String, String) {
|
|
||||||
(
|
|
||||||
String::from("What a twist!"),
|
|
||||||
String::from("soaricarus_test"),
|
|
||||||
String::from("soaricarus"),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
mod test_data {
|
mod test_data {
|
||||||
|
pub const TEST_USER_ID: uuid::Uuid = uuid::uuid!("cc938368-615a-4694-b2ca-6e122fa31c52");
|
||||||
|
|
||||||
pub const DEVICE_TYPE: &str = "BROWSER";
|
pub const DEVICE_TYPE: &str = "BROWSER";
|
||||||
pub const NAME: &str = "DougDimmaDome Browser Queue";
|
pub const NAME: &str = "DougDimmaDome Browser Queue";
|
||||||
}
|
|
||||||
|
|
||||||
pub const TEST_USER_ID: uuid::Uuid = uuid::uuid!("cc938368-615a-4694-b2ca-6e122fa31c52");
|
|
||||||
|
|
||||||
pub async fn test_token() -> Result<String, josekit::JoseError> {
|
pub async fn test_token() -> Result<String, josekit::JoseError> {
|
||||||
let key: String = sienvy::environment::get_secret_main_key().value;
|
let key: String = sienvy::environment::get_secret_main_key().value;
|
||||||
@@ -169,8 +160,17 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn token_fields() -> (String, String, String) {
|
||||||
|
(
|
||||||
|
"What a twist!".to_string(),
|
||||||
|
"soaricarus_test".to_string(),
|
||||||
|
"soaricarus".to_string(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn bearer_auth() -> String {
|
pub async fn bearer_auth() -> String {
|
||||||
let token = match test_token().await {
|
let token = match test_data::test_token().await {
|
||||||
Ok(access_token) => access_token,
|
Ok(access_token) => access_token,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
assert!(false, "Error: {err:?}");
|
assert!(false, "Error: {err:?}");
|
||||||
@@ -663,7 +663,7 @@ mod tests {
|
|||||||
let song_queue_id = resp.data[0];
|
let song_queue_id = resp.data[0];
|
||||||
assert_eq!(false, song_queue_id.is_nil(), "Should not be empty");
|
assert_eq!(false, song_queue_id.is_nil(), "Should not be empty");
|
||||||
|
|
||||||
let user_id = super::TEST_USER_ID;
|
let user_id = super::test_data::TEST_USER_ID;
|
||||||
|
|
||||||
match super::request::song_queue_link_req(&app, &song_queue_id, &user_id).await
|
match super::request::song_queue_link_req(&app, &song_queue_id, &user_id).await
|
||||||
{
|
{
|
||||||
@@ -968,7 +968,7 @@ mod tests {
|
|||||||
assert_eq!(false, resp.data[0].is_nil(), "Should not be empty");
|
assert_eq!(false, resp.data[0].is_nil(), "Should not be empty");
|
||||||
|
|
||||||
let song_queue_id = &resp.data[0];
|
let song_queue_id = &resp.data[0];
|
||||||
let user_id = TEST_USER_ID;
|
let user_id = test_data::TEST_USER_ID;
|
||||||
println!("User Id: {user_id:?}");
|
println!("User Id: {user_id:?}");
|
||||||
|
|
||||||
match request::song_queue_link_req(&app, &song_queue_id, &user_id).await {
|
match request::song_queue_link_req(&app, &song_queue_id, &user_id).await {
|
||||||
@@ -2655,7 +2655,7 @@ mod tests {
|
|||||||
super::db_mgr::migrations(&pool).await;
|
super::db_mgr::migrations(&pool).await;
|
||||||
|
|
||||||
let app = super::init::app(pool).await;
|
let app = super::init::app(pool).await;
|
||||||
let user_id = super::TEST_USER_ID;
|
let user_id = super::test_data::TEST_USER_ID;
|
||||||
let device_type = super::test_data::DEVICE_TYPE;
|
let device_type = super::test_data::DEVICE_TYPE;
|
||||||
let name = super::test_data::NAME;
|
let name = super::test_data::NAME;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user