54 lines
1.4 KiB
Go
54 lines
1.4 KiB
Go
package status
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
"testing"
|
|
|
|
"iop/packages/config"
|
|
)
|
|
|
|
func TestNewChecker_CodexUsesProfileCommand(t *testing.T) {
|
|
checker, err := NewChecker("codex", config.CLIProfileConf{
|
|
Command: "/tmp/mycodex",
|
|
})
|
|
if err != nil {
|
|
t.Fatalf("NewChecker failed: %v", err)
|
|
}
|
|
|
|
codex, ok := checker.(*CodexChecker)
|
|
if !ok {
|
|
t.Fatalf("expected *CodexChecker, got %T", checker)
|
|
}
|
|
|
|
if codex.command != "/tmp/mycodex" {
|
|
t.Errorf("expected command /tmp/mycodex, got %q", codex.command)
|
|
}
|
|
}
|
|
|
|
func TestNewChecker_FallbackToCmdBase(t *testing.T) {
|
|
checker, err := NewChecker("some-other", config.CLIProfileConf{
|
|
Command: "/usr/bin/codex",
|
|
})
|
|
if err != nil {
|
|
t.Fatalf("NewChecker failed: %v", err)
|
|
}
|
|
|
|
if _, ok := checker.(*CodexChecker); !ok {
|
|
t.Errorf("expected *CodexChecker for command ending in codex, got %T", checker)
|
|
}
|
|
}
|
|
|
|
func TestUnsupportedAgentReturnsError(t *testing.T) {
|
|
_, err := CheckUsage(context.Background(), "unknown", config.CLIProfileConf{Command: "unknown"})
|
|
if err == nil || !strings.Contains(err.Error(), "status check not supported") {
|
|
t.Errorf("expected not supported error, got %v", err)
|
|
}
|
|
}
|
|
|
|
func TestClaudeReturnsNotImplemented(t *testing.T) {
|
|
_, err := CheckUsage(context.Background(), "claude", config.CLIProfileConf{Command: "claude"})
|
|
if err == nil || !strings.Contains(err.Error(), "claude status not implemented") {
|
|
t.Errorf("expected claude not implemented error, got %v", err)
|
|
}
|
|
}
|