MCPcopy Index your code
hub / github.com/coder/coder / TestValidate

Function TestValidate

scripts/aibridgepricesgen/main_test.go:134–159  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

132}
133
134func TestValidate(t *testing.T) {
135 t.Parallel()
136
137 t.Run("PassesWhenAnyRowHasPricing", func(t *testing.T) {
138 t.Parallel()
139 rows := []priceRow{
140 {Provider: "openai", Model: "no-prices"},
141 {Provider: "anthropic", Model: "claude", InputPrice: int64Ptr(3_000_000)},
142 }
143 require.NoError(t, validate(rows))
144 })
145
146 t.Run("FailsWhenNoRowHasPricing", func(t *testing.T) {
147 t.Parallel()
148 // Mirrors what would happen if upstream renamed the `cost` key:
149 // Go's decoder silently drops it, every row gets all-null prices,
150 // and convert returns syntactically valid rows with no pricing.
151 rows := []priceRow{
152 {Provider: "anthropic", Model: "claude-x"},
153 {Provider: "openai", Model: "gpt-x"},
154 }
155 err := validate(rows)
156 require.Error(t, err)
157 require.Contains(t, err.Error(), "converted rows have no pricing data")
158 })
159}
160
161func floatPtr(v float64) *float64 { return &v }
162func int64Ptr(v int64) *int64 { return &v }

Callers

nothing calls this directly

Calls 5

int64PtrFunction · 0.70
validateFunction · 0.70
RunMethod · 0.65
ErrorMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected