Compiler improvements (#753)

* basic redis add

* toml; reverted unnecessary changes

* merge issues

* increased test connections

---------

Co-authored-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
This commit is contained in:
Wyatt Verchere
2023-11-19 19:10:13 -08:00
committed by GitHub
parent e06a77af28
commit dfba6c7c91
22 changed files with 307 additions and 140 deletions

View File

@@ -40,20 +40,21 @@ async fn test_get_project() {
assert_eq!(versions[0], json!(alpha_version_id));
// Confirm that the request was cached
let mut redis_pool = test_env.db.redis_pool.connect().await.unwrap();
assert_eq!(
test_env
.db
.redis_pool
.get::<i64, _>(PROJECTS_SLUGS_NAMESPACE, alpha_project_slug)
redis_pool
.get(PROJECTS_SLUGS_NAMESPACE, alpha_project_slug)
.await
.unwrap(),
.unwrap()
.and_then(|x| x.parse::<i64>().ok()),
Some(parse_base62(alpha_project_id).unwrap() as i64)
);
let cached_project = test_env
.db
.redis_pool
.get::<String, _>(PROJECTS_NAMESPACE, parse_base62(alpha_project_id).unwrap())
let cached_project = redis_pool
.get(
PROJECTS_NAMESPACE,
&parse_base62(alpha_project_id).unwrap().to_string(),
)
.await
.unwrap()
.unwrap();
@@ -249,22 +250,21 @@ async fn test_add_remove_project() {
assert_eq!(resp.status(), 204);
// Confirm that the project is gone from the cache
let mut redis_pool = test_env.db.redis_pool.connect().await.unwrap();
assert_eq!(
test_env
.db
.redis_pool
.get::<i64, _>(PROJECTS_SLUGS_NAMESPACE, "demo")
redis_pool
.get(PROJECTS_SLUGS_NAMESPACE, "demo")
.await
.unwrap(),
.unwrap()
.and_then(|x| x.parse::<i64>().ok()),
None
);
assert_eq!(
test_env
.db
.redis_pool
.get::<i64, _>(PROJECTS_SLUGS_NAMESPACE, id)
redis_pool
.get(PROJECTS_SLUGS_NAMESPACE, &id)
.await
.unwrap(),
.unwrap()
.and_then(|x| x.parse::<i64>().ok()),
None
);

View File

@@ -20,7 +20,7 @@ mod common;
#[actix_rt::test]
async fn search_projects() {
// Test setup and dummy data
let test_env = TestEnvironment::build(Some(8)).await;
let test_env = TestEnvironment::build(Some(10)).await;
let api = &test_env.v3;
let test_name = test_env.db.database_name.clone();

View File

@@ -221,22 +221,21 @@ async fn test_add_remove_project() {
assert_eq!(resp.status(), 204);
// Confirm that the project is gone from the cache
let mut redis_conn = test_env.db.redis_pool.connect().await.unwrap();
assert_eq!(
test_env
.db
.redis_pool
.get::<i64, _>(PROJECTS_SLUGS_NAMESPACE, "demo")
redis_conn
.get(PROJECTS_SLUGS_NAMESPACE, "demo")
.await
.unwrap(),
.unwrap()
.map(|x| x.parse::<i64>().unwrap()),
None
);
assert_eq!(
test_env
.db
.redis_pool
.get::<i64, _>(PROJECTS_SLUGS_NAMESPACE, id)
redis_conn
.get(PROJECTS_SLUGS_NAMESPACE, &id)
.await
.unwrap(),
.unwrap()
.map(|x| x.parse::<i64>().unwrap()),
None
);

View File

@@ -17,7 +17,7 @@ async fn search_projects() {
// It should drastically simplify this function
// Test setup and dummy data
let test_env = TestEnvironment::build(Some(8)).await;
let test_env = TestEnvironment::build(Some(10)).await;
let api = &test_env.v2;
let test_name = test_env.db.database_name.clone();

View File

@@ -33,10 +33,12 @@ async fn test_get_version() {
assert_eq!(&version.project_id.to_string(), alpha_project_id);
assert_eq!(&version.id.to_string(), alpha_version_id);
let cached_project = test_env
.db
.redis_pool
.get::<String, _>(VERSIONS_NAMESPACE, parse_base62(alpha_version_id).unwrap())
let mut redis_conn = test_env.db.redis_pool.connect().await.unwrap();
let cached_project = redis_conn
.get(
VERSIONS_NAMESPACE,
&parse_base62(alpha_version_id).unwrap().to_string(),
)
.await
.unwrap()
.unwrap();