MCPcopy Create free account
hub / github.com/compozy/agh / TestSessionPromptJSONLOutput

Function TestSessionPromptJSONLOutput

internal/cli/session_test.go:900–989  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

898}
899
900func TestSessionPromptJSONLOutput(t *testing.T) {
901 t.Run("Should stream prompt events as JSONL without buffering the completed turn", func(t *testing.T) {
902 t.Parallel()
903
904 var streamCalled bool
905 deps := newTestDeps(t, &stubClient{
906 promptSessionFn: func(context.Context, string, string) ([]AgentEventRecord, error) {
907 t.Fatal("PromptSession should not be called for prompt -o jsonl")
908 return nil, nil
909 },
910 streamPromptSessionFn: func(_ context.Context, id string, message string, handler SSEHandler) error {
911 streamCalled = true
912 if id != "sess-1" || message != "hello" {
913 t.Fatalf("StreamPromptSession() = (%q, %q), want (sess-1, hello)", id, message)
914 }
915 events := []SSEEvent{
916 {
917 Data: mustJSON(t, map[string]any{
918 "type": "start",
919 "messageId": "turn-1",
920 }),
921 },
922 {
923 Data: mustJSON(t, map[string]any{
924 "type": "text-start",
925 "id": "turn-1-text",
926 }),
927 },
928 {
929 Data: mustJSON(t, map[string]any{
930 "type": "text-delta",
931 "id": "turn-1-text",
932 "delta": "hello back",
933 }),
934 },
935 {
936 Data: mustJSON(t, map[string]any{
937 "type": "text-end",
938 "id": "turn-1-text",
939 }),
940 },
941 {
942 Data: mustJSON(t, map[string]any{
943 "type": "finish",
944 "finishReason": "stop",
945 }),
946 },
947 {
948 Data: []byte("[DONE]"),
949 },
950 }
951 for _, event := range events {
952 if err := handler(event); err != nil {
953 return err
954 }
955 }
956 return nil
957 },

Callers

nothing calls this directly

Calls 6

newTestDepsFunction · 0.85
executeRootCommandFunction · 0.85
appendFunction · 0.85
mustJSONFunction · 0.70
RunMethod · 0.65
handlerFunction · 0.50

Tested by

no test coverage detected