- add: initial database and auth services

This commit is contained in:
2024-11-25 20:45:16 -05:00
parent 6a35b5b373
commit 3ff22c9a5b
24 changed files with 817 additions and 1 deletions

View File

@@ -0,0 +1,25 @@
use tonic::{Request, Response};
use database_service::database::database_service_server::DatabaseService;
use database_service::database::GetUserRequest;
use database_service::MyDatabaseService;
#[tokio::test]
async fn test_grpc_get_user() {
let pool = setup_test_pool().await; // Set up your test pool
let cache = setup_test_cache().await; // Set up mock Redis cache
let service = MyDatabaseService { pool, cache };
// Create a mock gRPC request
let request = Request::new(GetUserRequest {
user_id: 123,
});
// Call the service
let response = service.get_user(request).await.unwrap().into_inner();
// Validate the response
assert_eq!(response.user_id, 123);
assert_eq!(response.username, "test_user");
assert_eq!(response.email, "test@example.com");
}