chore: use db util method to check publication status

This commit is contained in:
Aravinth Manivannan
2023-06-30 16:33:20 +05:30
parent 3c6b13f947
commit 6834e555d8

View File

@@ -343,17 +343,11 @@ pub mod tests {
assert_eq!(get_level_resp.status(), StatusCode::OK); assert_eq!(get_level_resp.status(), StatusCode::OK);
let res_levels: Vec<Level> = test::read_body_json(get_level_resp).await; let res_levels: Vec<Level> = test::read_body_json(get_level_resp).await;
assert_eq!(res_levels, default_levels); assert_eq!(res_levels, default_levels);
let publish_benchmarks = match data assert!(!data
.db .db
.analytics_get_psuedo_id_from_capmaign_id(&token_key.key) .analytics_captcha_is_published(&token_key.key)
.await .await
{ .unwrap());
Ok(_) => Ok(true),
Err(db_core::errors::DBError::CaptchaNotFound) => Ok(false),
Err(e) => Err(e),
}
.unwrap();
assert!(!publish_benchmarks);
// END create_easy // END create_easy
// START update_easy // START update_easy
@@ -386,9 +380,9 @@ pub mod tests {
assert_eq!(update_token_resp.status(), StatusCode::OK); assert_eq!(update_token_resp.status(), StatusCode::OK);
assert!(data assert!(data
.db .db
.analytics_get_psuedo_id_from_capmaign_id(&token_key.key) .analytics_captcha_is_published(&token_key.key)
.await .await
.is_ok()); .unwrap());
let get_level_resp = test::call_service( let get_level_resp = test::call_service(
&app, &app,
@@ -452,9 +446,9 @@ pub mod tests {
assert!(data assert!(data
.db .db
.analytics_get_psuedo_id_from_capmaign_id(&token_key.key) .analytics_captcha_is_published(&token_key.key)
.await .await
.is_ok()); .unwrap());
let token_key2: MCaptchaDetails = test::read_body_json(add_token_resp).await; let token_key2: MCaptchaDetails = test::read_body_json(add_token_resp).await;
@@ -473,15 +467,10 @@ pub mod tests {
) )
.await; .await;
assert_eq!(update_token_resp.status(), StatusCode::OK); assert_eq!(update_token_resp.status(), StatusCode::OK);
assert_eq!( assert!(!data
format!( .db
"{:?}", .analytics_captcha_is_published(&token_key2.key)
data.db .await
.analytics_get_psuedo_id_from_capmaign_id(&token_key2.key) .unwrap());
.await
.err()
),
format!("{:?}", Some(db_core::errors::DBError::CaptchaNotFound))
);
} }
} }