Skip to content

Commit a41d371

Browse files
Merge pull request #8 from stackql/feat/add-tests
Feat/add tests
2 parents fb6bb96 + d7b93f8 commit a41d371

File tree

12 files changed

+6393
-95
lines changed

12 files changed

+6393
-95
lines changed

.github/workflows/stackql-assert.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
run: | ## use the base64 encoded secret to create json file
2121
sudo echo ${{ secrets.GOOGLE_CREDS }} | base64 -d > sa-key.json
2222
23-
- name: query test statement example with auth_obj_path
23+
- name: Use test query string and expected results string with auth object
2424
uses: ./
2525
with:
2626
auth_obj_path: './.github/workflows/workflow_scripts/auth.json'
@@ -31,14 +31,14 @@ jobs:
3131
WHERE project = 'stackql-demo' AND zone = 'australia-southeast1-a' AND name = 'stackql-demo-001';
3232
expected_results_str: ' [{"name":"stackql-demo-001","status":"TERMINATED"}]'
3333

34-
- name: query test file example with auth_obj_path
34+
- name: Use test query file and expected result string with auth object
3535
uses: ./
3636
with:
3737
auth_obj_path: './.github/workflows/workflow_scripts/auth.json'
3838
test_query_file_path: './.github/workflows/workflow_scripts/google-example.iql'
3939
expected_results_str: ' [{"name":"stackql-demo-001","status":"TERMINATED"}]'
4040

41-
- name: query test statement example with auth string
41+
- name: Use test query string and expected results string, with auth string
4242
uses: ./
4343
with:
4444
auth_str: '{ "google": { "type": "service_account", "credentialsfilepath": "sa-key.json" }}'
@@ -49,19 +49,19 @@ jobs:
4949
WHERE project = 'stackql-demo' AND zone = 'australia-southeast1-a' AND name = 'stackql-demo-001';
5050
expected_results_str: '[{"name":"stackql-demo-001","status":"TERMINATED"}]'
5151

52-
- name: query test file example with auth string
52+
- name: Use test query string and expected results file, with auth object
5353
uses: ./
5454
with:
55-
auth_str: '{ "google": { "type": "service_account", "credentialsfilepath": "sa-key.json" }}'
55+
auth_obj_path: './.github/workflows/workflow_scripts/auth.json'
5656
test_query_file_path: './.github/workflows/workflow_scripts/google-example.iql'
5757
expected_results_str: '[{"name":"stackql-demo-001","status":"TERMINATED"}]'
5858

59-
- name: query test file while expected result is a file
59+
- name: Use test query string and expected rows, with auth object
6060
uses: ./
6161
with:
6262
auth_str: '{ "google": { "type": "service_account", "credentialsfilepath": "sa-key.json" }}'
6363
test_query_file_path: './.github/workflows/workflow_scripts/google-example.iql'
64-
expected_results_file_path: './.github/workflows/workflow_scripts/expected_results.json'
64+
expected_rows: 1
6565

6666

6767

.github/workflows/test.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: 'Build and Test'
2+
on:
3+
push:
4+
pull_request:
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v3
12+
- name: Use Node.js 16
13+
uses: actions/setup-node@v3
14+
with:
15+
node-version: 16.x
16+
- run: npm ci
17+
- run: npm test
18+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.stackql/readline/readline.tmp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
REGISTRY PULL github v23.01.00104;
2+
REGISTRY PULL github;
3+
SHOW PROVIDERS ;
4+
SHOW PROVIDERS;
5+
REGISTRY PULL google v23.01.00116;
6+
REGISTER PULL github latest;
7+
REGISTRY PULL github latest;

action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ inputs:
1818
description: expected number of rows from executing test query
1919
required: false
2020
expected_results_str:
21-
description: expected result from executing test query, support object string
21+
description: expected result from executing test query, support object string, overrides expected_results_file_path
2222
required: false
2323
expected_results_file_path:
2424
description: file that stores expected result, json is support
@@ -57,7 +57,7 @@ runs:
5757
uses: actions/github-script@v6
5858
with:
5959
script: |
60-
const assertResult = require('./action_scripts/assert.js')
60+
const {assertResult} = require('./stackql-assert.js')
6161
assertResult(core)
6262
env:
6363
RESULT: ${{steps.exec-query.outputs.stdout}}

action_scripts/assert.js

Lines changed: 0 additions & 86 deletions
This file was deleted.

0 commit comments

Comments
 (0)