@@ -849,6 +849,52 @@ func TestInput(t *testing.T) {
849
849
autogold .ExpectFile (t , toJSONString (t , resp ), autogold .Name (t .Name ()+ "/step2" ))
850
850
}
851
851
852
+ func TestOutput (t * testing.T ) {
853
+ if runtime .GOOS == "windows" {
854
+ t .Skip ()
855
+ }
856
+
857
+ r := tester .NewRunner (t )
858
+ r .RespondWith (tester.Result {
859
+ Text : "Response 1" ,
860
+ })
861
+
862
+ prg , err := r .Load ("" )
863
+ require .NoError (t , err )
864
+
865
+ resp , err := r .Chat (context .Background (), nil , prg , nil , "Input 1" )
866
+ require .NoError (t , err )
867
+ r .AssertResponded (t )
868
+ assert .False (t , resp .Done )
869
+ autogold .Expect (`CHAT: true CONTENT: Response 1 CONTINUATION: true FINISH: false suffix
870
+ ` ).Equal (t , resp .Content )
871
+ autogold .ExpectFile (t , toJSONString (t , resp ), autogold .Name (t .Name ()+ "/step1" ))
872
+
873
+ r .RespondWith (tester.Result {
874
+ Text : "Response 2" ,
875
+ })
876
+ resp , err = r .Chat (context .Background (), resp .State , prg , nil , "Input 2" )
877
+ require .NoError (t , err )
878
+ r .AssertResponded (t )
879
+ assert .False (t , resp .Done )
880
+ autogold .Expect (`CHAT: true CONTENT: Response 2 CONTINUATION: true FINISH: false suffix
881
+ ` ).Equal (t , resp .Content )
882
+ autogold .ExpectFile (t , toJSONString (t , resp ), autogold .Name (t .Name ()+ "/step2" ))
883
+
884
+ r .RespondWith (tester.Result {
885
+ Err : & engine.ErrChatFinish {
886
+ Message : "Chat Done" ,
887
+ },
888
+ })
889
+ resp , err = r .Chat (context .Background (), resp .State , prg , nil , "Input 3" )
890
+ require .NoError (t , err )
891
+ r .AssertResponded (t )
892
+ assert .True (t , resp .Done )
893
+ autogold .Expect (`CHAT FINISH: CHAT: true CONTENT: Chat Done CONTINUATION: false FINISH: true suffix
894
+ ` ).Equal (t , resp .Content )
895
+ autogold .ExpectFile (t , toJSONString (t , resp ), autogold .Name (t .Name ()+ "/step3" ))
896
+ }
897
+
852
898
func TestSysContext (t * testing.T ) {
853
899
if runtime .GOOS == "windows" {
854
900
t .Skip ()
0 commit comments