-
Notifications
You must be signed in to change notification settings - Fork 444
refactor: consolidate duplicated model-normalization helpers (pkg/cli ↔ pkg/modelsdev) #43340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8b04c84
7977a11
cd5b183
3c3bab3
f88f40f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -146,3 +146,36 @@ func TestFindPricing(t *testing.T) { | |
| assert.Nil(t, pricing) | ||
| }) | ||
| } | ||
|
|
||
| func TestNormalizeProvider(t *testing.T) { | ||
| cases := []struct{ input, want string }{ | ||
| {"github", "github-copilot"}, | ||
| {"copilot", "github-copilot"}, | ||
| {"github_models", "github-copilot"}, | ||
| {"GITHUB_MODELS", "github-copilot"}, | ||
| {"anthropic", "anthropic"}, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [/tdd] 💡 Suggested additional case{"GitHub_Models", "github-copilot"},Adding it turns the test suite into a living specification for alias matching, and prevents a future refactor from accidentally dropping case-insensitive handling. @copilot please address this. |
||
| {"OpenAI", "openai"}, | ||
| {" Anthropic ", "anthropic"}, | ||
| {"", ""}, | ||
| } | ||
| for _, tc := range cases { | ||
| t.Run(tc.input+"->"+tc.want, func(t *testing.T) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unaddressable sub-test name: when 💡 Suggested fixApply the same guard used in the CLI test (model_costs_test.go:41): for _, tc := range cases {
name := tc.input + "->" + tc.want
if tc.input == "" {
name = "<empty>->" + tc.want
}
t.Run(name, func(t *testing.T) {
assert.Equal(t, tc.want, NormalizeProvider(tc.input))
})
}Without this, |
||
| assert.Equal(t, tc.want, NormalizeProvider(tc.input)) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestNormalizeComparableModelID(t *testing.T) { | ||
| cases := []struct{ input, want string }{ | ||
| {"claude-sonnet-4.6", "claude-sonnet-4-6"}, | ||
| {"gpt_4o", "gpt-4o"}, | ||
| {"GPT-4O", "gpt-4o"}, | ||
| {" claude.3 ", "claude-3"}, | ||
| {"", ""}, | ||
| } | ||
| for _, tc := range cases { | ||
| t.Run(tc.input+"->"+tc.want, func(t *testing.T) { | ||
| assert.Equal(t, tc.want, NormalizeComparableModelID(tc.input)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [/tdd] 💡 Suggested additional case{"gpt-4o", "gpt-4o"}, // already canonical — idempotency check@copilot please address this. |
||
| }) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[/codebase-design]
TestNormalizeCatalogProvidernow testsmodelsdev.NormalizeProvider, making its name stale — and its cases are a subset of the newTestNormalizeProviderincatalog_test.go, so the coverage is duplicated.💡 Suggested fix
Either remove this test entirely (canonical coverage already lives in
pkg/modelsdev/catalog_test.go), or rename it and replace the cases with an integration-level test that goes throughfindModelPricingwith a provider alias to verify the wiring end-to-end. Keeping it as-is means a failure reportsTestNormalizeCatalogProviderwhen the function named in the message isNormalizeProvider, which is confusing.@copilot please address this.