on main help sign in
test: simplify integration tests, run for a single provider / model
4e66adaAndrey Nering
internal/agent/.env.sample+1
@@ -1,4 +1,5 @@
1CRUSH_ANTHROPIC_API_KEY=
1CRUSH_ANTHROPIC_API_KEY=
2+CRUSH_HYPER_API_KEY=
2CRUSH_OPENAI_API_KEY=
3CRUSH_OPENAI_API_KEY=
3CRUSH_OPENROUTER_API_KEY=
4CRUSH_OPENROUTER_API_KEY=
4CRUSH_ZAI_API_KEY=
5CRUSH_ZAI_API_KEY=
internal/agent/agent_test.go+1−4
@@ -26,10 +26,7 @@ func TestMain(m *testing.M) {
26}
26}
27
27
28var modelPairs = []modelPair{
28var modelPairs = []modelPair{
29− {"anthropic-sonnet", anthropicBuilder("claude-sonnet-4-6"), anthropicBuilder("claude-haiku-4-5-20251001")},
29+ {"glm-5.1", hyperBuilder("glm-5.1"), hyperBuilder("gpt-oss-120b")},
30− {"openai-gpt-5", openaiBuilder("gpt-5"), openaiBuilder("gpt-4o")},
31− {"openrouter-kimi-k2", openRouterBuilder("moonshotai/kimi-k2-0905"), openRouterBuilder("qwen/qwen3-next-80b-a3b-instruct")},
32− {"zai-glm4.6", zAIBuilder("glm-4.6"), zAIBuilder("glm-4.5-air")},
33}
30}
34
31
35func getModels(t *testing.T, r *vcr.Recorder, pair modelPair) (fantasy.LanguageModel, fantasy.LanguageModel) {
32func getModels(t *testing.T, r *vcr.Recorder, pair modelPair) (fantasy.LanguageModel, fantasy.LanguageModel) {
internal/agent/common_test.go+3−45
@@ -10,10 +10,7 @@ import (
10
10
11 "charm.land/catwalk/pkg/catwalk"
11 "charm.land/catwalk/pkg/catwalk"
12 "charm.land/fantasy"
12 "charm.land/fantasy"
13− "charm.land/fantasy/providers/anthropic"
14− "charm.land/fantasy/providers/openai"
15 "charm.land/fantasy/providers/openaicompat"
13 "charm.land/fantasy/providers/openaicompat"
16− "charm.land/fantasy/providers/openrouter"
17 "charm.land/x/vcr"
14 "charm.land/x/vcr"
18 "github.com/charmbracelet/crush/internal/agent/prompt"
15 "github.com/charmbracelet/crush/internal/agent/prompt"
19 "github.com/charmbracelet/crush/internal/agent/tools"
16 "github.com/charmbracelet/crush/internal/agent/tools"
@@ -50,50 +47,11 @@ type modelPair struct {
50 smallModel builderFunc
47 smallModel builderFunc
51}
48}
52
49
53−func anthropicBuilder(model string) builderFunc {
54− return func(t *testing.T, r *vcr.Recorder) (fantasy.LanguageModel, error) {
55− provider, err := anthropic.New(
56− anthropic.WithAPIKey(os.Getenv("CRUSH_ANTHROPIC_API_KEY")),
57− anthropic.WithHTTPClient(&http.Client{Transport: r}),
58− )
59− if err != nil {
60− return nil, err
61− }
62− return provider.LanguageModel(t.Context(), model)
63− }
64−}
65−
66−func openaiBuilder(model string) builderFunc {
67− return func(t *testing.T, r *vcr.Recorder) (fantasy.LanguageModel, error) {
68− provider, err := openai.New(
69− openai.WithAPIKey(os.Getenv("CRUSH_OPENAI_API_KEY")),
70− openai.WithHTTPClient(&http.Client{Transport: r}),
71− )
72− if err != nil {
73− return nil, err
74− }
75− return provider.LanguageModel(t.Context(), model)
76− }
77−}
78−
79−func openRouterBuilder(model string) builderFunc {
80− return func(t *testing.T, r *vcr.Recorder) (fantasy.LanguageModel, error) {
81− provider, err := openrouter.New(
82− openrouter.WithAPIKey(os.Getenv("CRUSH_OPENROUTER_API_KEY")),
83− openrouter.WithHTTPClient(&http.Client{Transport: r}),
84− )
85− if err != nil {
86− return nil, err
87− }
88− return provider.LanguageModel(t.Context(), model)
89− }
90−}
91−
92−func zAIBuilder(model string) builderFunc {
50+func hyperBuilder(model string) builderFunc {
93 return func(t *testing.T, r *vcr.Recorder) (fantasy.LanguageModel, error) {
51 return func(t *testing.T, r *vcr.Recorder) (fantasy.LanguageModel, error) {
94 provider, err := openaicompat.New(
52 provider, err := openaicompat.New(
95− openaicompat.WithBaseURL("https://api.z.ai/api/coding/paas/v4"),
53+ openaicompat.WithBaseURL("https://hyper.charm.land/v1"),
96− openaicompat.WithAPIKey(os.Getenv("CRUSH_ZAI_API_KEY")),
54+ openaicompat.WithAPIKey(os.Getenv("CRUSH_HYPER_API_KEY")),
97 openaicompat.WithHTTPClient(&http.Client{Transport: r}),
55 openaicompat.WithHTTPClient(&http.Client{Transport: r}),
98 )
56 )
99 if err != nil {
57 if err != nil {