mirror of
https://github.com/Twigpine/zero.git
synced 2026-11-08 09:49:34 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e871fde39d | ||
|
|
99721c762f |
No files matched your search
@@ -2254,6 +2254,19 @@ func TestResolveRejectsInvalidCrossSessionInbound(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestResolveReportsExplicitMaxTurns(t *testing.T) {
|
||||
// A nil ResolveOptions.Env means "read the real process environment" (see
|
||||
// envValue), so a case that leaves it nil inherits whatever the developer
|
||||
// happens to export. ANTHROPIC_BASE_URL alone is enough: applyProviderEnv
|
||||
// synthesizes a second, keyless "anthropic" profile from a base URL on its
|
||||
// own, the single-provider shortcut in normalizeProviders stops applying,
|
||||
// and Resolve fails with `active provider "" not found` before this test
|
||||
// reaches its assertion. Every variable the resolver reads does it, so the
|
||||
// cases below state an EMPTY environment rather than no environment, and
|
||||
// these three are set to a hostile value so the test proves it.
|
||||
t.Setenv("ANTHROPIC_BASE_URL", "https://proxy.example/v1")
|
||||
t.Setenv("OPENAI_API_KEY", "from-the-developer-shell")
|
||||
t.Setenv(MaxTurnsEnv, "7")
|
||||
|
||||
const providerJSON = `{
|
||||
"activeProvider": "p",
|
||||
"providers": [{"name": "p", "provider_kind": "openai-compatible", "base_url": "https://x.example/v1", "apiKey": "k", "model": "m"}]
|
||||
@@ -2266,10 +2279,15 @@ func TestResolveReportsExplicitMaxTurns(t *testing.T) {
|
||||
set bool
|
||||
}{
|
||||
{"built-in default only", ResolveOptions{
|
||||
Env: map[string]string{},
|
||||
Overrides: Overrides{Provider: ProviderProfile{Name: "p", ProviderKind: "openai-compatible", BaseURL: "https://x.example/v1", APIKey: "k", Model: "m"}},
|
||||
}, false},
|
||||
{"user config", ResolveOptions{UserConfigPath: writeConfig(t, providerWithTurns)}, true},
|
||||
{"user config", ResolveOptions{
|
||||
Env: map[string]string{},
|
||||
UserConfigPath: writeConfig(t, providerWithTurns),
|
||||
}, true},
|
||||
{"project config", ResolveOptions{
|
||||
Env: map[string]string{},
|
||||
UserConfigPath: writeConfig(t, providerJSON),
|
||||
ProjectConfigPath: writeConfig(t, `{"maxTurns": 40}`),
|
||||
}, true},
|
||||
@@ -2278,6 +2296,7 @@ func TestResolveReportsExplicitMaxTurns(t *testing.T) {
|
||||
Overrides: Overrides{Provider: ProviderProfile{Name: "p", ProviderKind: "openai-compatible", BaseURL: "https://x.example/v1", APIKey: "k", Model: "m"}},
|
||||
}, true},
|
||||
{"cli override", ResolveOptions{
|
||||
Env: map[string]string{},
|
||||
Overrides: Overrides{
|
||||
MaxTurns: 42,
|
||||
Provider: ProviderProfile{Name: "p", ProviderKind: "openai-compatible", BaseURL: "https://x.example/v1", APIKey: "k", Model: "m"},
|
||||
|
||||
@@ -2,6 +2,7 @@ package tui
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -112,7 +113,22 @@ func TestMouseWheelOnClippedFooterStatusDoesNotMoveComposerCursor(t *testing.T)
|
||||
}
|
||||
|
||||
func TestAltScreenTranscriptScrollKeepsFooterFixed(t *testing.T) {
|
||||
m := newModel(context.Background(), Options{AltScreen: true, ProviderName: "openai", ModelName: "gpt-4.1"})
|
||||
// Cwd is pinned because an empty Options.Cwd makes newModel take the real
|
||||
// working directory, which at test time is this package inside whoever's
|
||||
// checkout, and the branch assertion below is not a monotonic function of
|
||||
// that path's length. The title bar picks the widest candidate that fits:
|
||||
// workspace carries branch AND path, cwdOnly carries only the path, and
|
||||
// compactLeft carries only the branch. At width 90 with this branch, a cwd
|
||||
// of up to 52 bytes keeps branch and path, 53 to 74 falls to path-only and
|
||||
// loses the branch, and 75 or more falls again to branch-only and gets it
|
||||
// back. So this failed from a checkout 74 bytes deep and passed from one 80
|
||||
// bytes deep, while CI sits at 40 and never sees it.
|
||||
m := newModel(context.Background(), Options{
|
||||
AltScreen: true,
|
||||
ProviderName: "openai",
|
||||
ModelName: "gpt-4.1",
|
||||
Cwd: filepath.Join(string(filepath.Separator), "workspace", "zero"),
|
||||
})
|
||||
m.width = 90
|
||||
m.height = 10
|
||||
m.gitBranch = "feat/pinned-header"
|
||||
|
||||
Reference in new issue
Block a user