summaryrefslogtreecommitdiff
path: root/internal/api/server_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/api/server_test.go')
-rw-r--r--internal/api/server_test.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/internal/api/server_test.go b/internal/api/server_test.go
index a670f33..4899a5c 100644
--- a/internal/api/server_test.go
+++ b/internal/api/server_test.go
@@ -147,14 +147,16 @@ func testServerWithGeminiMockRunner(t *testing.T) (*Server, *storage.DB) {
mockBinDir := t.TempDir()
mockGeminiPath := filepath.Join(mockBinDir, "mock-gemini-binary.sh")
mockScriptContent := `#!/bin/bash
-# Mock gemini binary that outputs stream-json wrapped in markdown to stdout.
-echo "```json"
-echo "{\"type\":\"content_block_start\",\"content_block\":{\"text\":\"Hello, Gemini!\",\"type\":\"text\"}}"
-echo "{\"type\":\"content_block_delta\",\"content_block\":{\"text\":\" How are you?\"}}"
-echo "{\"type\":\"content_block_end\"}"
-echo "{\"type\":\"message_delta\",\"message\":{\"role\":\"model\"}}"
-echo "{\"type\":\"message_end\"}"
-echo "```"
+OUTPUT_FILE=$(mktemp)
+echo "` + "```json" + `" > "$OUTPUT_FILE"
+echo "{\"type\":\"content_block_start\",\"content_block\":{\"text\":\"Hello, Gemini!\",\"type\":\"text\"}}" >> "$OUTPUT_FILE"
+echo "{\"type\":\"content_block_delta\",\"content_block\":{\"text\":\" How are you?\"}}" >> "$OUTPUT_FILE"
+echo "{\"type\":\"content_block_end\"}" >> "$OUTPUT_FILE"
+echo "{\"type\":\"message_delta\",\"message\":{\"role\":\"model\"}}" >> "$OUTPUT_FILE"
+echo "{\"type\":\"message_end\"}" >> "$OUTPUT_FILE"
+echo "` + "```" + `" >> "$OUTPUT_FILE"
+cat "$OUTPUT_FILE"
+rm "$OUTPUT_FILE"
exit 0
`
if err := os.WriteFile(mockGeminiPath, []byte(mockScriptContent), 0755); err != nil {