Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Behind The Math committed Feb 6, 2024
1 parent fef57fe commit 3d2bb44
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@ on: push
jobs:
jewish-date:
runs-on: ubuntu-latest
container: mysql:5.7
defaults:
run:
shell: bash
env:
MYSQL_ALLOW_EMPTY_PASSWORD: 1
MYSQL_DATABASE: db1
MYSQL_INITDB_SKIP_TZINFO: 1
steps:
- uses: actions/checkout@v3
- run: docker compose up -d -f ./tests/docker-compose.yml
- run: |
while true; do
mysql -u root --batch --database db1 --execute 'SELECT 1;' && break;
docker exec mysql mysql -u root --batch --database db1 --execute 'SELECT 1;' && break;
sleep 1;
done;
- run: bash ./tests/hebrewcalendar/jewish-date/run-tests.sh
- run: bash $GITHUB_WORKSPACE/tests/hebrewcalendar/jewish-date/run-tests.sh
env:
MYSQL_CMD: docker exec mysql mysql
- run: docker compose down
10 changes: 10 additions & 0 deletions tests/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: '3.9'
services:
mysql:
image: 'mysql:5.7'
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: true
MYSQL_DATABASE: db1
MYSQL_INITDB_SKIP_TZINFO: true
volumes:
- $GITHUB_WORKSPACE/hebrewcalendar:/docker-entrypoint-initdb.d/hebrewcalendar:ro
2 changes: 1 addition & 1 deletion tests/hebrewcalendar/jewish-date/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ for line in "${lines[@]}"; do
sql="CALL gregorian_date_to_jewish_date($gregorian, @jewishYear, @jewishMonth, @jewishDay); SELECT @jewishYear, @jewishMonth, @jewishDay;"

# The `tail` is needed to drop out the following output: `failed to get console mode for stdout: The handle is invalid.`
output=$(mysql -u root --batch --database db1 --skip-column-names --execute "$sql" | sed 's/\t/,/g' | tail -n 1)
output=$($MYSQL_CMD -u root --batch --database db1 --skip-column-names --execute "$sql" | sed 's/\t/,/g' | tail -n 1)
printf " Output: '%s'\n" "$output"

if [[ "$output" == "$expected" ]]
Expand Down

0 comments on commit 3d2bb44

Please sign in to comment.