@@ -404,6 +404,42 @@ func TestParseSimpleFile(t *testing.T) {
404404 }
405405}
406406
407+ func TestParseFileWithMetadata (t * testing.T ) {
408+ wd , err := os .Getwd ()
409+ if err != nil {
410+ t .Fatalf ("Error getting working directory: %v" , err )
411+ }
412+
413+ tools , err := g .Parse (context .Background (), wd + "/test/parse-with-metadata.gpt" )
414+ if err != nil {
415+ t .Errorf ("Error parsing file: %v" , err )
416+ }
417+
418+ if len (tools ) != 2 {
419+ t .Fatalf ("Unexpected number of tools: %d" , len (tools ))
420+ }
421+
422+ if tools [0 ].ToolNode == nil {
423+ t .Fatalf ("No tool node found" )
424+ }
425+
426+ if ! strings .Contains (tools [0 ].ToolNode .Tool .Instructions , "requests.get(" ) {
427+ t .Errorf ("Unexpected instructions: %s" , tools [0 ].ToolNode .Tool .Instructions )
428+ }
429+
430+ if tools [0 ].ToolNode .Tool .MetaData ["requirements.txt" ] != "requests" {
431+ t .Errorf ("Unexpected metadata: %s" , tools [0 ].ToolNode .Tool .MetaData ["requirements.txt" ])
432+ }
433+
434+ if tools [1 ].TextNode == nil {
435+ t .Fatalf ("No text node found" )
436+ }
437+
438+ if tools [1 ].TextNode .Fmt != "metadata:foo:requirements.txt" {
439+ t .Errorf ("Unexpected text: %s" , tools [1 ].TextNode .Fmt )
440+ }
441+ }
442+
407443func TestParseTool (t * testing.T ) {
408444 tools , err := g .ParseTool (context .Background (), "echo hello" )
409445 if err != nil {
@@ -1069,3 +1105,24 @@ func TestGetEnv(t *testing.T) {
10691105 })
10701106 }
10711107}
1108+
1109+ func TestRunPythonWithMetadata (t * testing.T ) {
1110+ wd , err := os .Getwd ()
1111+ if err != nil {
1112+ t .Fatalf ("Error getting working directory: %v" , err )
1113+ }
1114+
1115+ run , err := g .Run (context .Background (), wd + "/test/parse-with-metadata.gpt" , Options {IncludeEvents : true })
1116+ if err != nil {
1117+ t .Fatalf ("Error executing file: %v" , err )
1118+ }
1119+
1120+ out , err := run .Text ()
1121+ if err != nil {
1122+ t .Fatalf ("Error reading output: %v" , err )
1123+ }
1124+
1125+ if out != "200" {
1126+ t .Errorf ("Unexpected output: %s" , out )
1127+ }
1128+ }
0 commit comments