@@ -241,6 +241,15 @@ describe("gptscript module", () => {
241
241
expect ( ( response [ 0 ] as gptscript . Tool ) . instructions ) . toEqual ( "who was the president in 1928?" )
242
242
} , 30000 )
243
243
244
+ test ( "parse file with metadata" , async ( ) => {
245
+ const response = await g . parse ( path . join ( __dirname , "fixtures" , "parse-with-metadata.gpt" ) )
246
+ expect ( response ) . toBeDefined ( )
247
+ expect ( response ) . toHaveLength ( 2 )
248
+ expect ( ( response [ 0 ] as gptscript . Tool ) . instructions ) . toContain ( "requests.get" )
249
+ expect ( ( response [ 0 ] as gptscript . Tool ) . metaData ) . toEqual ( { "requirements.txt" : "requests" } )
250
+ expect ( ( response [ 1 ] as gptscript . Text ) . format ) . toEqual ( "metadata:foo:requirements.txt" )
251
+ } , 30000 )
252
+
244
253
test ( "parse string tool" , async ( ) => {
245
254
const tool = "How much wood would a woodchuck chuck if a woodchuck could chuck wood?"
246
255
const response = await g . parseTool ( tool )
@@ -537,13 +546,27 @@ describe("gptscript module", () => {
537
546
} )
538
547
539
548
test ( "test get_env default" , async ( ) => {
540
- const env = getEnv ( ' TEST_ENV_MISSING' , ' foo' )
541
- expect ( env ) . toEqual ( ' foo' )
549
+ const env = getEnv ( " TEST_ENV_MISSING" , " foo" )
550
+ expect ( env ) . toEqual ( " foo" )
542
551
} )
543
552
544
553
test ( "test get_env" , async ( ) => {
545
- process . env . TEST_ENV = '{"_gz":"H4sIAEosrGYC/ytJLS5RKEvMKU0FACtB3ewKAAAA"}'
546
- const env = getEnv ( 'TEST_ENV' , 'missing' )
547
- expect ( env ) . toEqual ( 'test value' )
554
+ process . env . TEST_ENV = "{\"_gz\":\"H4sIAEosrGYC/ytJLS5RKEvMKU0FACtB3ewKAAAA\"}"
555
+ const env = getEnv ( "TEST_ENV" , "missing" )
556
+ expect ( env ) . toEqual ( "test value" )
557
+ } )
558
+
559
+ test ( "run file with metadata" , async ( ) => {
560
+ let err = undefined
561
+ let out = ""
562
+ let run = await g . run ( path . join ( __dirname , "fixtures" , "parse-with-metadata.gpt" ) )
563
+
564
+ try {
565
+ out = await run . text ( )
566
+ } catch ( e ) {
567
+ err = e
568
+ }
569
+ expect ( err ) . toEqual ( undefined )
570
+ expect ( out ) . toEqual ( "200" )
548
571
} )
549
- } )
572
+ } )
0 commit comments