Skip to content

Commit e31f9e9

Browse files
author
Sylvestre Gug
committed
basic config
1 parent 4876030 commit e31f9e9

File tree

6 files changed

+496
-27
lines changed

6 files changed

+496
-27
lines changed
File renamed without changes.

.github/workflows/test.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Test
2+
on: push
3+
4+
jobs:
5+
test:
6+
runs-on: ubuntu-20.04
7+
defaults:
8+
run:
9+
working-directory: .
10+
env:
11+
DOCKER_PACKAGE: ghcr.io/${{ github.repository }}/database-proxy_test
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Docker login
16+
run: echo ${GITHUB_TOKEN} | docker login -u ${GITHUB_ACTOR} --password-stdin ghcr.io
17+
env:
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
20+
- name: Republish
21+
id: republish
22+
continue-on-error: true
23+
if: ${{ needs.Changes.outputs.connector == 'false' }}
24+
run: |
25+
../.github/retry docker pull ${DOCKER_PACKAGE}:${{ github.event.before }}
26+
docker tag ${DOCKER_PACKAGE}:${{ github.event.before }} ${DOCKER_PACKAGE}:${GITHUB_SHA}
27+
../.github/retry docker push ${DOCKER_PACKAGE}:${GITHUB_SHA}
28+
29+
- name: Build
30+
if: ${{ steps.republish.outcome != 'success' }}
31+
run: |
32+
touch .env.test
33+
docker-compose build
34+
- name: Lint
35+
if: ${{ steps.republish.outcome != 'success' }}
36+
run: docker-compose run lint
37+
- name: Test
38+
if: ${{ steps.republish.outcome != 'success' }}
39+
run: docker-compose run test
40+
- name: Container logs
41+
if: failure()
42+
run: docker-compose logs --no-color --timestamps
43+
- name: Publish
44+
if: ${{ steps.republish.outcome != 'success' }}
45+
run: |
46+
docker tag database-proxy_test:latest ${DOCKER_PACKAGE}:${GITHUB_SHA}
47+
../.github/retry docker push ${DOCKER_PACKAGE}:${GITHUB_SHA}

docker-compose.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
version: "3.7"
22

33
services:
4+
lint:
5+
build: .
6+
command: eslint .
7+
48
test:
59
build: .
610
depends_on:

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,13 @@
3636
"@babel/preset-env": "^7.19.4",
3737
"@babel/register": "^7.18.9",
3838
"chai": "^4.3.6",
39+
"eslint": "^8.32.0",
40+
"eslint-plugin-prettier": "^4.2.1",
3941
"mocha": "^10.1.0",
4042
"mock-req": "^0.2.0",
4143
"mock-res": "^0.6.0",
4244
"nodemon": "^1.19.1",
45+
"prettier": "^2.8.3",
4346
"wait-on": "^6.0.1"
4447
},
4548
"peerDependencies": {

test/mssql.test.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe("mssql", () => {
3232

3333
describe("when querying", () => {
3434
it("should stream the results of simple query", () => {
35-
return new Promise(async (resolve, reject) => {
35+
return new Promise((resolve) => {
3636
const req = new MockReq({method: "POST", url: "/query-stream"}).end({
3737
sql: "SELECT TOP 2 CustomerID FROM test.SalesLT.Customer",
3838
params: [],
@@ -41,7 +41,7 @@ describe("mssql", () => {
4141
const res = new MockRes(onEnd);
4242

4343
const index = mssql(credentials);
44-
await index(req, res);
44+
index(req, res);
4545

4646
function onEnd() {
4747
const [schema, row] = this._getString().split("\n");
@@ -62,17 +62,18 @@ describe("mssql", () => {
6262
});
6363
});
6464
it("should handle parameter graciously", () => {
65-
return new Promise(async (resolve, reject) => {
65+
return new Promise((resolve) => {
6666
const testCustomerId = 3;
6767
const req = new MockReq({method: "POST", url: "/query-stream"}).end({
68-
sql: "SELECT TOP 2 CustomerID FROM test.SalesLT.Customer WHERE CustomerID=@1",
68+
sql:
69+
"SELECT TOP 2 CustomerID FROM test.SalesLT.Customer WHERE CustomerID=@1",
6970
params: [testCustomerId],
7071
});
7172

7273
const res = new MockRes(onEnd);
7374

7475
const index = mssql(credentials);
75-
await index(req, res);
76+
index(req, res);
7677

7778
function onEnd() {
7879
const [schema, row] = this._getString().split("\n");
@@ -93,17 +94,18 @@ describe("mssql", () => {
9394
});
9495
});
9596
it("should replace cell reference in the SQL query", () => {
96-
return new Promise(async (resolve, reject) => {
97+
return new Promise((resolve) => {
9798
const testCustomerId = 5;
9899
const req = new MockReq({method: "POST", url: "/query-stream"}).end({
99-
sql: "SELECT TOP 2 CustomerID FROM test.SalesLT.Customer WHERE CustomerID=@1",
100+
sql:
101+
"SELECT TOP 2 CustomerID FROM test.SalesLT.Customer WHERE CustomerID=@1",
100102
params: [testCustomerId],
101103
});
102104

103105
const res = new MockRes(onEnd);
104106

105107
const index = mssql(credentials);
106-
await index(req, res);
108+
index(req, res);
107109

108110
function onEnd() {
109111
const [schema, row] = this._getString().split("\n");
@@ -124,7 +126,7 @@ describe("mssql", () => {
124126
});
125127
});
126128
it("should handle duplicated column names", () => {
127-
return new Promise(async (resolve, reject) => {
129+
return new Promise((resolve) => {
128130
const req = new MockReq({method: "POST", url: "/query-stream"}).end({
129131
sql: "SELECT 1 as _a1, 2 as _a1 FROM test.SalesLT.SalesOrderDetail",
130132
params: [],
@@ -133,10 +135,10 @@ describe("mssql", () => {
133135
const res = new MockRes(onEnd);
134136

135137
const index = mssql(credentials);
136-
await index(req, res);
138+
index(req, res);
137139

138140
function onEnd() {
139-
const [schema, row] = this._getString().split("\n");
141+
const [, row] = this._getString().split("\n");
140142

141143
expect(row).to.equal(
142144
JSON.stringify({
@@ -149,16 +151,17 @@ describe("mssql", () => {
149151
});
150152
});
151153
it("should select the last value of any detected duplicated columns", () => {
152-
return new Promise(async (resolve, reject) => {
154+
return new Promise((resolve) => {
153155
const req = new MockReq({method: "POST", url: "/query-stream"}).end({
154-
sql: "SELECT TOP 1 ModifiedDate, ModifiedDate FROM test.SalesLT.SalesOrderDetail",
156+
sql:
157+
"SELECT TOP 1 ModifiedDate, ModifiedDate FROM test.SalesLT.SalesOrderDetail",
155158
params: [],
156159
});
157160

158161
const res = new MockRes(onEnd);
159162

160163
const index = mssql(credentials);
161-
await index(req, res);
164+
index(req, res);
162165

163166
function onEnd() {
164167
const [schema, row] = this._getString().split("\n");

0 commit comments

Comments
 (0)