From f66e778662fade66b5bcfae7a326c834502b47c6 Mon Sep 17 00:00:00 2001 From: Vitaliy Demidov Date: Sun, 18 Feb 2024 16:46:48 -0800 Subject: [PATCH] Added more test. --- .github/workflows/default.yml | 10 +++++--- tests/test_sort_order.sql | 28 +++++++++++++++++++++ tests.sql => tests/test_version_compare.sql | 0 3 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 tests/test_sort_order.sql rename tests.sql => tests/test_version_compare.sql (100%) diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index 53cab3a..b6da7f3 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -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 diff --git a/tests/test_sort_order.sql b/tests/test_sort_order.sql new file mode 100644 index 0000000..e4cb709 --- /dev/null +++ b/tests/test_sort_order.sql @@ -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; + diff --git a/tests.sql b/tests/test_version_compare.sql similarity index 100% rename from tests.sql rename to tests/test_version_compare.sql