generated from bcgov/quickstart-openshift
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add tests for TPS permit migration trigger (#1094)
- Loading branch information
1 parent
995faf6
commit 21a135e
Showing
5 changed files
with
156 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
-- Test that the trigger populates the ORBC_PERMIT table with | ||
-- correct data and valid ORIGINAL_ID | ||
SET NOCOUNT ON | ||
INSERT INTO $(DB_NAME).tps.ORBC_TPS_MIGRATED_PERMITS( | ||
PERMIT_TYPE, | ||
START_DATE, | ||
END_DATE, | ||
ISSUED_DATE, | ||
CLIENT_HASH, | ||
PLATE, | ||
VIN, | ||
PERMIT_NUMBER, | ||
NEW_PERMIT_NUMBER, | ||
PERMIT_GENERATION, | ||
SERVICE) | ||
VALUES( | ||
'TROS', | ||
'20240101', | ||
'20240201', | ||
'20240101 12:00:00PM', | ||
'HASH', | ||
'TSTPLT', | ||
'TSTVIN', | ||
'08-100-3429', | ||
'P0-08100342-900', | ||
1, | ||
'C') | ||
|
||
SELECT COUNT(*) FROM $(DB_NAME).permit.ORBC_PERMIT | ||
WHERE | ||
PERMIT_NUMBER = 'P0-08100342-900' | ||
AND | ||
REVISION = 0 | ||
AND | ||
PERMIT_APPROVAL_SOURCE_TYPE = 'TPS' | ||
AND | ||
ORIGINAL_ID = ID | ||
AND | ||
PERMIT_STATUS_TYPE = 'ISSUED' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
-- Test that duplicate records are not migrated into ORBC_PERMIT | ||
SET NOCOUNT ON | ||
INSERT INTO $(DB_NAME).tps.ORBC_TPS_MIGRATED_PERMITS( | ||
PERMIT_TYPE, | ||
START_DATE, | ||
END_DATE, | ||
ISSUED_DATE, | ||
CLIENT_HASH, | ||
PLATE, | ||
VIN, | ||
PERMIT_NUMBER, | ||
NEW_PERMIT_NUMBER, | ||
PERMIT_GENERATION, | ||
SERVICE) | ||
VALUES( | ||
'TROS', | ||
'20240101', | ||
'20240201', | ||
'20240101 12:00:00PM', | ||
'HASH', | ||
'TSTPLT', | ||
'TSTVIN', | ||
'08-100-3429', | ||
'P0-08100342-900', | ||
1, | ||
'C') | ||
|
||
SELECT COUNT(*) FROM $(DB_NAME).permit.ORBC_PERMIT -- should be still just one, from prior test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
-- Test that the trigger sets the correct permit number, and | ||
-- that the previous rev id is set correctly | ||
SET NOCOUNT ON | ||
INSERT INTO $(DB_NAME).tps.ORBC_TPS_MIGRATED_PERMITS( | ||
PERMIT_TYPE, | ||
START_DATE, | ||
END_DATE, | ||
ISSUED_DATE, | ||
CLIENT_HASH, | ||
PLATE, | ||
VIN, | ||
PERMIT_NUMBER, | ||
NEW_PERMIT_NUMBER, | ||
PERMIT_GENERATION, | ||
SERVICE) | ||
VALUES( | ||
'TROS', | ||
'20240101', | ||
'20240201', | ||
'20240101 12:00:00PM', | ||
'HASH', | ||
'TSTPLT2', | ||
'TSTVIN', | ||
'08-100-3429', | ||
'P0-08100342-911-A01', -- changing the incoming permit number to test | ||
2, -- previous revision was 1, this is next one | ||
'C') | ||
|
||
SELECT COUNT(*) FROM $(DB_NAME).permit.ORBC_PERMIT | ||
WHERE | ||
PERMIT_NUMBER = 'P0-08100342-900-A01' | ||
AND | ||
REVISION = 1 | ||
AND | ||
PERMIT_APPROVAL_SOURCE_TYPE = 'TPS' | ||
AND | ||
ORIGINAL_ID = (SELECT ID FROM $(DB_NAME).permit.ORBC_PERMIT WHERE PERMIT_NUMBER = 'P0-08100342-900') | ||
AND | ||
PERMIT_STATUS_TYPE = 'ISSUED' | ||
AND | ||
PREVIOUS_REV_ID = (SELECT ID FROM $(DB_NAME).permit.ORBC_PERMIT WHERE PERMIT_NUMBER = 'P0-08100342-900') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-- Test that the trigger sets previous revision to SUPERSEDED | ||
SET NOCOUNT ON | ||
SELECT COUNT(*) FROM $(DB_NAME).permit.ORBC_PERMIT | ||
WHERE | ||
PERMIT_NUMBER = 'P0-08100342-900' | ||
AND | ||
REVISION = 0 | ||
AND | ||
PERMIT_APPROVAL_SOURCE_TYPE = 'TPS' | ||
AND | ||
PERMIT_STATUS_TYPE = 'SUPERSEDED' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
|
||
# Retrieve arguments | ||
source ${SCRIPT_DIR}/utility/getopt.sh | ||
USAGE="-u USER -p PASS -s SERVER -d DATABASE" | ||
parse_options "${USAGE}" ${@} | ||
|
||
# All database tests for database version 12 are run from this shell script. | ||
# TESTS_DIR variable set by the calling test-runner script. | ||
|
||
TEST_12_1_RESULT=$(/opt/mssql-tools/bin/sqlcmd -U ${USER} -P "${PASS}" -S ${SERVER} -v DB_NAME=${DATABASE} -h -1 -i ${TESTS_DIR}/v_12_1_test.sql | xargs) | ||
if [[ $TEST_12_1_RESULT -eq 1 ]]; then | ||
echo "Test 12.1 passed: Trigger is populating records into ORBC_PERMIT" | ||
else | ||
echo "******** Test 12.1 failed: Trigger not populating records into ORBC_PERMIT" | ||
fi | ||
|
||
TEST_12_2_RESULT=$(/opt/mssql-tools/bin/sqlcmd -U ${USER} -P "${PASS}" -S ${SERVER} -v DB_NAME=${DATABASE} -h -1 -i ${TESTS_DIR}/v_12_2_test.sql | xargs) | ||
if [[ $TEST_12_2_RESULT -eq 1 ]]; then | ||
echo "Test 12.2 passed: Duplicate records not being inserted into ORBC_PERMIT" | ||
else | ||
echo "******** Test 12.2 failed: Duplicate records being inserted into ORBC_PERMIT" | ||
fi | ||
|
||
TEST_12_3_RESULT=$(/opt/mssql-tools/bin/sqlcmd -U ${USER} -P "${PASS}" -S ${SERVER} -v DB_NAME=${DATABASE} -h -1 -i ${TESTS_DIR}/v_12_3_test.sql | xargs) | ||
if [[ $TEST_12_3_RESULT -eq 1 ]]; then | ||
echo "Test 12.3 passed: Permit number of amendments being adjusted correctly" | ||
else | ||
echo "******** Test 12.3 failed: Permit number of amendments not being adjusted correctly" | ||
fi | ||
|
||
TEST_12_4_RESULT=$(/opt/mssql-tools/bin/sqlcmd -U ${USER} -P "${PASS}" -S ${SERVER} -v DB_NAME=${DATABASE} -h -1 -i ${TESTS_DIR}/v_12_4_test.sql | xargs) | ||
if [[ $TEST_12_4_RESULT -eq 1 ]]; then | ||
echo "Test 12.4 passed: Previous revisions correctly marked SUPERSEDED" | ||
else | ||
echo "******** Test 12.4 failed: Previous revisions not being marked SUPERSEDED" | ||
fi |