Skip to content

Commit 5eefcc1

Browse files
committed
Add workflow for running gateway tests
1 parent 89bc57f commit 5eefcc1

File tree

3 files changed

+36
-7
lines changed

3 files changed

+36
-7
lines changed

.github/workflows/run_tests.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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: Start gateway and run tests
19+
run: |
20+
npm run dev &
21+
echo "Waiting for gateway to start..."
22+
while ! curl -s http://localhost:8787 > /dev/null; do
23+
sleep 1
24+
done
25+
echo "Gateway is ready. Running tests..."
26+
npm run test:gateway
27+
28+
env:
29+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
30+
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)