tarakan-client/internal/agent/grok_stream_live_test.go
Maxfield Luke 58b29a7f84
Some checks failed
CI and releases / Test and vet (push) Failing after 1s
CI and releases / Build release binaries (push) Has been skipped
CI and releases / Publish GitHub release (push) Has been skipped
Initial commit on Forgejo
Fresh repository history for elektrine/tarakan-client hosted at
https://git.elektrine.com/elektrine/tarakan-client.
2026-07-29 04:56:36 -04:00

50 lines
1.2 KiB
Go

//go:build live
package agent
import (
"context"
"os"
"os/exec"
"path/filepath"
"strings"
"sync"
"testing"
"time"
)
func TestGrokLiveToolProgress(t *testing.T) {
if _, err := exec.LookPath("grok"); err != nil {
t.Skip("grok not installed")
}
dir := t.TempDir()
if err := os.WriteFile(filepath.Join(dir, "sample.txt"), []byte("hello world\n"), 0o600); err != nil {
t.Fatal(err)
}
path, _ := exec.LookPath("grok")
p := Provider{Name: "grok", Kind: KindCLI, Command: "grok", Description: "Grok Build", Path: path}
var mu sync.Mutex
var lines []string
ctx, cancel := context.WithTimeout(context.Background(), 90*time.Second)
defer cancel()
out, err := Run(ctx, p, Request{
Prompt: "Read sample.txt and reply with only the file contents.",
Directory: dir,
Progress: func(s string) {
mu.Lock()
lines = append(lines, s)
mu.Unlock()
t.Log("progress:", s)
},
})
if err != nil {
t.Fatalf("run: %v out=%q", err, out)
}
joined := strings.Join(lines, "\n")
if !strings.Contains(joined, "Read") && !strings.Contains(joined, "sample.txt") {
t.Fatalf("expected read activity in progress:\n%s", joined)
}
if !strings.Contains(out, "hello") {
t.Fatalf("output = %q", out)
}
}