Skip to content

Commit

Permalink
Added more test.
Browse files Browse the repository at this point in the history
  • Loading branch information
recipe committed Feb 19, 2024
1 parent 752e3a2 commit f66e778
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ jobs:
- uses: actions/checkout@v3

- name: Set up stored functions
run: mysql -uroot -proot test_db < ./semver.sql
run: |
mysql -uroot -proot test_db < ./semver.sql
mysql -uroot -proot test_db < ./append_version.sql
- name: Run tests
run: if mysql -uroot -proot test_db < ./tests.sql | egrep '.'; then exit 1; fi
- name: Test VERSION_COMPARE(version1, version2)
run: if mysql -uroot -proot test_db < ./tests/test_version_compare.sql | egrep '.'; then exit 1; fi

- name: Test GET_SORT_ORDER(version)
run: if mysql -uroot -proot test_db < ./tests/test_sort_order.sql | egrep -B100 'Test failed'; then exit 1; fi
28 changes: 28 additions & 0 deletions tests/test_sort_order.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
INSERT `versions` (`version`, `sort_order`)
SELECT t.column_0 AS `version`, 0 AS `sort_order`
FROM (VALUES
ROW ('1.0-beta'),
ROW ('2-alpha'),
ROW ('1.3'),
ROW ('1.4.34'),
ROW ('2.0.12-beta.1'),
ROW ('1.3-beta.2'),
ROW ('1.3-beta-2'),
ROW ('1.3-beta2'),
ROW ('1'),
ROW ('1.2'),
ROW ('alpha'),
ROW('1.0.0-2021-08-19'),
ROW('11.0.0.1'),
ROW('11.0.0.1.8.22'),
ROW('1.0.0-canary.3'),
ROW('1.0.1-alpha-3'),
ROW('1.0.1-rc20')
) t
ORDER BY RAND();


SELECT `id`, `version`, `sort_order` FROM `versions` ORDER BY `sort_order`;

SELECT IF(GROUP_CONCAT(version) = 'alpha,1.0.0-2021-08-19,1.0-beta,1.0.0-canary.3,1,1.0.1-alpha-3,1.0.1-rc20,1.2,1.3-beta-2,1.3-beta.2,1.3-beta2,1.3,1.4.34,2-alpha,2.0.12-beta.1,11.0.0.1,11.0.0.1.8.22', 'OK!', 'Test failed!') FROM versions ORDER BY sort_order;

File renamed without changes.

0 comments on commit f66e778

Please sign in to comment.