38 lines
980 B
Go
38 lines
980 B
Go
|
|
package cli
|
||
|
|
|
||
|
|
import (
|
||
|
|
"bytes"
|
||
|
|
"strings"
|
||
|
|
"testing"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestBuildAppConfiguresSetupCommand(t *testing.T) {
|
||
|
|
stdin := strings.NewReader("imap.example.com\nalice\nsecret\n")
|
||
|
|
stdout := &bytes.Buffer{}
|
||
|
|
stderr := &bytes.Buffer{}
|
||
|
|
app := buildApp(stdin, stdout, stderr)
|
||
|
|
|
||
|
|
err := app.Run([]string{"setup"})
|
||
|
|
if err == nil {
|
||
|
|
t.Fatal("expected placeholder store error")
|
||
|
|
}
|
||
|
|
if err.Error() != errSecretStoreNotConfigured.Error() {
|
||
|
|
t.Fatalf("expected placeholder store error, got %v", err)
|
||
|
|
}
|
||
|
|
if got := stderr.String(); got != "IMAP host: Username: Password: " {
|
||
|
|
t.Fatalf("expected setup prompts on stderr, got %q", got)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func TestBuildAppConfiguresMCPCommand(t *testing.T) {
|
||
|
|
app := buildApp(strings.NewReader(""), &bytes.Buffer{}, &bytes.Buffer{})
|
||
|
|
|
||
|
|
err := app.Run([]string{"mcp"})
|
||
|
|
if err == nil {
|
||
|
|
t.Fatal("expected placeholder runner error")
|
||
|
|
}
|
||
|
|
if err.Error() != errMCPRunnerNotConfigured.Error() {
|
||
|
|
t.Fatalf("expected placeholder runner error, got %v", err)
|
||
|
|
}
|
||
|
|
}
|