File tree Expand file tree Collapse file tree 3 files changed +38
-9
lines changed Expand file tree Collapse file tree 3 files changed +38
-9
lines changed Original file line number Diff line number Diff line change 4545
4646 - name : Run tests
4747 run : ./scripts/test
48+
49+ ecosystem_tests :
50+ name : ecosystem tests
51+ runs-on : ubuntu-latest
52+ if : github.repository == 'stainless-sdks/openai-typescript'
53+
54+ steps :
55+ - uses : actions/checkout@v4
56+
57+ - name : Set up Node
58+ uses : actions/setup-node@v4
59+ with :
60+ node-version : ' 18'
61+
62+ - uses : denoland/setup-deno@v1
63+ with :
64+ deno-version : v1.39.0
65+
66+ - uses : oven-sh/setup-bun@v2
67+
68+ - name : Bootstrap
69+ run : ./scripts/bootstrap
70+
71+ - name : Run ecosystem tests
72+ run : |
73+ echo 'OPENAI_API_KEY = "'"${OPENAI_API_KEY}"'"' >> ecosystem-tests/cloudflare-worker/wrangler.toml
74+ yarn tsn ecosystem-tests/cli.ts --live --verbose --parallel --jobs=4 --retry=3
75+ env :
76+ OPENAI_API_KEY : ${{ secrets.OPENAI_API_KEY }}
Original file line number Diff line number Diff line change 11import * as shims from 'openai/_shims/index' ;
2- import * as fd from 'formdata-node' ;
32
43test ( 'openai/shims/node' , ( ) => {
54 expect ( shims . kind ) . toEqual ( 'node' ) ;
6- expect ( shims . File ) . toBe ( fd . File ) ;
5+ expect ( shims . File ) . toBe ( File ) ;
76} ) ;
Original file line number Diff line number Diff line change @@ -54,13 +54,14 @@ it(`raw response`, async function () {
5454
5555 // test that we can use node-fetch Response API
5656 const chunks : string [ ] = [ ] ;
57- const { body } = response ;
58- if ( ! body ) throw new Error ( `expected response.body to be defined` ) ;
59- body . on ( 'data' , ( chunk ) => chunks . push ( chunk ) ) ;
60- await new Promise < void > ( ( resolve , reject ) => {
61- body . once ( 'end' , resolve ) ;
62- body . once ( 'error' , reject ) ;
63- } ) ;
57+ if ( ! response . body ) throw new Error ( `expected response.body to be defined` ) ;
58+
59+ const decoder = new TextDecoder ( ) ;
60+
61+ for await ( const chunk of response . body ) {
62+ chunks . push ( decoder . decode ( chunk ) ) ;
63+ }
64+
6465 const json : ChatCompletion = JSON . parse ( chunks . join ( '' ) ) ;
6566 expect ( json . choices [ 0 ] ?. message . content || '' ) . toBeSimilarTo ( 'This is a test' , 10 ) ;
6667} ) ;
You can’t perform that action at this time.
0 commit comments