Skip to content

Commit

Permalink
added some meaningful comments
Browse files Browse the repository at this point in the history
  • Loading branch information
swayam-agrahari committed Dec 12, 2024
1 parent 4119017 commit 3673c4c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
11 changes: 1 addition & 10 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Start PostgreSQL
run: |
docker run --name postgres-test -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=test_db -p 5432:5432 -d postgres:15
- name: Set TEST_DATABASE_URL
run: echo "TEST_DATABASE_URL=postgres://postgres:postgres@localhost:5432/test_db" >> $GITHUB_ENV

- name: Install Rust and Cargo
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source $HOME/.cargo/env
- name: Run Tests
run: cargo test

- uses: shuttle-hq/deploy-action@main
with:
name: "root"
deploy-key: ${{ secrets.SHUTTLE_API_KEY }}
secrets: |
ROOT_SECRET = '${{ secrets.ROOT_SECRET }}'
TEST_DATABASE_URL = '${{ secrets.TEST_DATABASE_URL }}'
12 changes: 3 additions & 9 deletions tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ async fn cleanup_test_data(pool: &PgPool) {
DECLARE
seq RECORD;
BEGIN
-- Truncate tables if they exist
-- Droppign all the tables for cleanup purpose
BEGIN
TRUNCATE TABLE leaderboard, leetcode_stats, codeforces_stats, member RESTART IDENTITY CASCADE;
EXCEPTION
Expand All @@ -100,7 +100,7 @@ async fn cleanup_test_data(pool: &PgPool) {
RAISE NOTICE 'Tables do not exist, skipping TRUNCATE.';
END;
-- Reset sequences only if they exist
-- Postgres stores the sequences of unique id outside of respective tables, so need to delete those too.
FOR seq IN
SELECT c.relname
FROM pg_class c
Expand All @@ -125,13 +125,11 @@ async fn cleanup_test_data(pool: &PgPool) {
}

#[tokio::test]
// Additional helper test to verify database connections and basic operations
async fn test_database_connection() {
let database_url = get_database_url();
println!("Database URL: {}", database_url);
assert!(!database_url.is_empty(), "Database URL should not be empty");
// let result = sqlx::query("SELECT 1").fetch_one(&pool).await;

// assert!(result.is_ok(), "Database connection and query should work");
}

//test
Expand Down Expand Up @@ -241,8 +239,6 @@ async fn test_insert_members_and_update_stats() {
),
Err(e) => {
println!("Error fetching Codeforces stats: {:?}", e);
// Uncomment to fail test on fetch error
// panic!("Failed to fetch Codeforces stats")
}
}
}
Expand Down Expand Up @@ -280,5 +276,3 @@ async fn test_insert_members_and_update_stats() {

cleanup_test_data(&pool).await;
}

// Additional helper test to verify database connections and basic operations

0 comments on commit 3673c4c

Please sign in to comment.