Skip to content

Commit

Permalink
Added a common script for running test cases of all services and upda…
Browse files Browse the repository at this point in the history
…ted test workflow file
  • Loading branch information
thejasmeetsingh committed Dec 31, 2023
1 parent d2836c9 commit 2cfef26
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 50 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
microservices:
- user_service
steps:
- uses: actions/checkout@v3
- name: Set up Go
Expand All @@ -22,6 +18,4 @@ jobs:
run: curl -fsSL https://github.com/raw/pressly/goose/master/install.sh | sh

- name: Execute Test Cases
run: |
cd ./src/${{ matrix.microservices }}
bash run_unit_test.sh
run: bash ./run_unit_test.sh
19 changes: 13 additions & 6 deletions src/product_service/run_unit_test.sh → run_unit_test.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/bin/bash/

container_name=test_products_db
container_name=test_db
db_user=db_user
db_password=1234
db_name=products_test_db
db_name=test

services=("user_service" "product_service")

# Run the testing database container
docker run --name $container_name \
Expand All @@ -30,11 +32,16 @@ done

sleep 30

# Run migrations
goose -dir sql/schema postgres postgres://$db_user:$db_password@localhost:5432/$db_name up
for service in ${services[@]};
do
echo "Runnig test for $service service"

cd src/$service
goose -dir sql/schema postgres postgres://$db_user:$db_password@localhost:5432/$db_name up
go test ./api/

# Run test case
go test ./api/
echo "---------------------"
done

# Stop & remove docker container
docker container stop $container_name
Expand Down
37 changes: 0 additions & 37 deletions src/user_service/run_unit_test.sh

This file was deleted.

0 comments on commit 2cfef26

Please sign in to comment.