@@ -241,6 +241,15 @@ describe("gptscript module", () => {
241241 expect ( ( response [ 0 ] as gptscript . Tool ) . instructions ) . toEqual ( "who was the president in 1928?" )
242242 } , 30000 )
243243
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+
244253 test ( "parse string tool" , async ( ) => {
245254 const tool = "How much wood would a woodchuck chuck if a woodchuck could chuck wood?"
246255 const response = await g . parseTool ( tool )
@@ -537,13 +546,27 @@ describe("gptscript module", () => {
537546 } )
538547
539548 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" )
542551 } )
543552
544553 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" )
548571 } )
549- } )
572+ } )
0 commit comments