Skip to content

Commit b9bea4b

Browse files
committed
Add YAML file for unit testing workflow
1 parent 6447eff commit b9bea4b

1 file changed

Lines changed: 99 additions & 0 deletions

File tree

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# This workflow installs tSQLt and runs the test units
2+
3+
name: tSQLt installer and unit testing runner
4+
5+
# Controls when the workflow will run
6+
on:
7+
# Triggers the workflow on push or pull request events but only for the "master" branch
8+
push:
9+
branches: [ "master" ]
10+
pull_request:
11+
branches: [ "master" ]
12+
13+
# Allows you to run this workflow manually from the Actions tab
14+
workflow_dispatch:
15+
16+
jobs:
17+
windows-auth-tsqlt:
18+
name: Installting tSQLt with SQL Auth
19+
# The type of runner that the job will run on
20+
runs-on: ubuntu-latest
21+
22+
services:
23+
sqlserver:
24+
image: chriseaton/adventureworks:latest
25+
ports:
26+
- 1433:1433
27+
env:
28+
ACCEPT_EULA: Y
29+
SA_PASSWORD: 3uuiCaKxfbForrK
30+
31+
steps:
32+
- uses: actions/checkout@v2
33+
34+
- name: Install tSQLt with SQL auth on tempdb
35+
uses: lowlydba/tsqlt-installer@v1
36+
with:
37+
sql-instance: localhost
38+
database: tempdb
39+
version: latest
40+
user: sa
41+
password: 3uuiCaKxfbForrK
42+
43+
#- name: Get the containers list unformatted
44+
# run: docker ps
45+
46+
#- name: Get the containers list formatted
47+
# run: docker ps --all --filter status=running --no-trunc --format "{{.ID}}"
48+
49+
#- name: Set the container ID
50+
# run: echo '::set-output name=CONTAINER_ID::$(docker ps --all --filter status=running --no-trunc --format "{{.ID}}")'
51+
# id: ContainerID
52+
53+
#- name: Get container ID
54+
# run: echo "The container ID is ${{ steps.ContainerID.outputs.CONTAINER_ID }}"
55+
56+
- name: Set environment variable ENV_CONTAINER_ID
57+
run: echo "ENV_CONTAINER_ID=$(docker ps --all --filter status=running --no-trunc --format "{{.ID}}")" >> $GITHUB_ENV
58+
59+
- name: Test environment variable ENV_CONTAINER_ID
60+
run: echo $ENV_CONTAINER_ID
61+
62+
#- name: Print environment variables
63+
# run: env
64+
65+
- name: Restore AdventureWorks2017
66+
run: docker exec -i $ENV_CONTAINER_ID /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "3uuiCaKxfbForrK" -Q "RESTORE DATABASE [AdventureWorks2017] FROM DISK = '/adventureworks.bak' WITH MOVE 'AdventureWorks2017' TO '/var/opt/mssql/data/AdventureWorks.mdf', MOVE 'AdventureWorks2017_log' TO '/var/opt/mssql/data/AdventureWorks_log.ldf'"
67+
68+
- name: Get the database list
69+
run: docker exec -i $ENV_CONTAINER_ID /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "3uuiCaKxfbForrK" -Q "SELECT Name FROM sys.databases"
70+
71+
- name: Install tSQLt with SQL auth on AdventureWorks2017
72+
uses: lowlydba/tsqlt-installer@v1
73+
with:
74+
sql-instance: localhost
75+
database: AdventureWorks2017
76+
version: latest
77+
user: sa
78+
password: 3uuiCaKxfbForrK
79+
80+
- name: Create sp usp_Raiserror_SafetyStockLevel
81+
run: docker exec -i $ENV_CONTAINER_ID /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "3uuiCaKxfbForrK" -d AdventureWorks2017 -b < ./source/usp-raiserror-safetystocklevel.sql
82+
83+
- name: Create system under test (SUT) TR_Product_SafetyStockLevel
84+
run: docker exec -i $ENV_CONTAINER_ID /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "3uuiCaKxfbForrK" -d AdventureWorks2017 -b < ./source/tr_product_safetystocklevel.sql
85+
86+
- name: Create test class UnitTestTRProductSafetyStockLevel
87+
run: docker exec -i $ENV_CONTAINER_ID /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "3uuiCaKxfbForrK" -d AdventureWorks2017 -b < ./unit-test/test-class-trproductsafetystocklevel.sql
88+
89+
- name: Create and run test case try to insert one wrong row
90+
run: docker exec -i $ENV_CONTAINER_ID /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "3uuiCaKxfbForrK" -d AdventureWorks2017 -b < ./unit-test/test-case-try-to-insert-one-wrong-row.sql
91+
92+
- name: Create and run test case try to insert one right row
93+
run: docker exec -i $ENV_CONTAINER_ID /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "3uuiCaKxfbForrK" -d AdventureWorks2017 -b < ./unit-test/test-case-try-to-insert-one-right-row.sql
94+
95+
- name: Create and run test case try to insert multiple rows
96+
run: docker exec -i $ENV_CONTAINER_ID /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "3uuiCaKxfbForrK" -d AdventureWorks2017 -b < ./unit-test/test-case-try-to-insert-multiple-rows.sql
97+
98+
- name: Create and run test case try to insert multiple rows ordered
99+
run: docker exec -i $ENV_CONTAINER_ID /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "3uuiCaKxfbForrK" -d AdventureWorks2017 -b < ./unit-test/test-case-try-to-insert-multiple-rows-ordered.sql

0 commit comments

Comments
 (0)