Skip to content

Commit 1650766

Browse files
authored
Merge pull request #707 from narengogi/chore/test-workflow
Add workflow for running gateway tests
2 parents 3460aca + 1c91466 commit 1650766

File tree

3 files changed

+38
-7
lines changed

3 files changed

+38
-7
lines changed

.github/workflows/run_tests.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Run Gateway tests
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
jobs:
8+
gateway-tests:
9+
runs-on: ubuntu-latest
10+
environment: production
11+
steps:
12+
- name: Checkout head
13+
uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
- name: Install dependencies
17+
run: npm ci
18+
- name: Build
19+
run: npm run build
20+
- name: Start gateway and run tests
21+
run: |
22+
npm run build/start-server.js &
23+
echo "Waiting for gateway to start..."
24+
while ! curl -s http://localhost:8787 > /dev/null; do
25+
sleep 1
26+
done
27+
echo "Gateway is ready. Running tests..."
28+
npm run test:gateway
29+
30+
env:
31+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
32+
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
"start:node": "node build/start-server.js",
3535
"format": "prettier --write \"./**/*.{js,jsx,ts,tsx,json}\"",
3636
"format:check": "prettier --check \"./**/*.{js,jsx,ts,tsx,json}\"",
37-
"test": "ts-jest",
37+
"test:gateway": "jest src/",
38+
"test:plugins": "jest plugins/",
3839
"pre-push": "npm run build && node start-test.js",
3940
"prepare": "node -e \"if (process.env.NODE_ENV !== 'production'){process.exit(1)} \" || husky"
4041
},

src/tests/routeSpecificTestFunctions.ts/chatCompletion.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,20 @@ export const executeChatCompletionEndpointTests: (
2121
}
2222

2323
test(`${providerName} /chat/completions test message strings`, async () => {
24-
const request = new Request(CHAT_COMPLETIONS_ENDPOINT, {
24+
const res = await fetch(CHAT_COMPLETIONS_ENDPOINT, {
2525
method: 'POST',
2626
headers: createDefaultHeaders(providerName, apiKey),
2727
body: getChatCompleteWithMessageStringRequest(model),
2828
});
29-
const res = await app.fetch(request);
30-
expect(res.status).toBe(200);
29+
expect(res.status).toEqual(200);
3130
});
3231

3332
test(`${providerName} /chat/completions test message content arrays`, async () => {
34-
const request = new Request(CHAT_COMPLETIONS_ENDPOINT, {
33+
const res = await fetch(CHAT_COMPLETIONS_ENDPOINT, {
3534
method: 'POST',
3635
headers: createDefaultHeaders(providerName, apiKey),
3736
body: getChatCompleteWithMessageContentArraysRequest(model),
3837
});
39-
const res = await app.fetch(request);
40-
expect(res.status).toBe(200);
38+
expect(res.status).toEqual(200);
4139
});
4240
};

0 commit comments

Comments
 (0)