Files

40 lines
1.3 KiB
Go
Raw Permalink Normal View History

package test
// Process-boundary tests for the diagnostic commands against a real daemon.
import (
"strings"
"testing"
)
// TestDoctorWithDaemon: when the daemon runs it is ✔ with version and log
// path; voices and test work as processes.
func TestDoctorWithDaemon(t *testing.T) {
root := t.TempDir()
fake := newFakeProvider(t, 0)
d := startDaemon(t, root, fake.srv.URL, nil)
env := daemonEnv(root, d.port, fake.srv.URL, nil)
res := runTalk(t, env, "doctor")
if res.code != 0 {
t.Fatalf("talk doctor: exit %d\n%s\n%s", res.code, res.stdout, res.stderr)
}
for _, want := range []string{"✔ Daemon", "running at " + d.baseURL, "daemon.log", "✔ elevenlabs", "key set"} {
if !strings.Contains(res.stdout, want) {
t.Errorf("doctor without %q:\n%s", want, res.stdout)
}
}
res = runTalk(t, env, "doctor", "--probe")
if res.code != 0 || !strings.Contains(res.stdout, "probe ok") {
t.Errorf("doctor --probe: exit %d\n%s", res.code, res.stdout)
}
fake.waitArrived(t, 1)
if res := runTalk(t, env, "voices"); res.code != 0 || !strings.HasPrefix(res.stdout, "PROVIDER") {
t.Errorf("talk voices: exit %d, stdout %q", res.code, res.stdout)
}
if res := runTalk(t, env, "test"); res.code != 0 || !strings.Contains(res.stdout, "provider: elevenlabs") {
t.Errorf("talk test: exit %d, stdout %q, stderr %q", res.code, res.stdout, res.stderr)
}
}