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

Function TestConvertMissingProvider

scripts/aibridgepricesgen/main_test.go:103–132  ·  view source on GitHub ↗

TestConvertMissingProvider covers both shapes of "configured provider has no usable data": the provider's key is absent from upstream, or the key exists but its Models map is empty. Both should fail loud so we never ship a partial seed.

(t *testing.T)

Source from the content-addressed store, hash-verified

101// exists but its Models map is empty. Both should fail loud so we never
102// ship a partial seed.
103func TestConvertMissingProvider(t *testing.T) {
104 t.Parallel()
105
106 t.Run("Absent", func(t *testing.T) {
107 t.Parallel()
108 upstream := map[string]upstreamProvider{
109 "openai": {Models: map[string]upstreamModel{
110 "gpt-4o": {Cost: &upstreamCost{Input: floatPtr(2.5)}},
111 }},
112 }
113 rows, err := convert(upstream, []string{"anthropic", "openai"})
114 require.Error(t, err)
115 require.Contains(t, err.Error(), "anthropic")
116 require.Nil(t, rows)
117 })
118
119 t.Run("EmptyModels", func(t *testing.T) {
120 t.Parallel()
121 upstream := map[string]upstreamProvider{
122 "anthropic": {Models: map[string]upstreamModel{}},
123 "openai": {Models: map[string]upstreamModel{
124 "gpt-4o": {Cost: &upstreamCost{Input: floatPtr(2.5)}},
125 }},
126 }
127 rows, err := convert(upstream, []string{"anthropic", "openai"})
128 require.Error(t, err)
129 require.Contains(t, err.Error(), "anthropic")
130 require.Nil(t, rows)
131 })
132}
133
134func TestValidate(t *testing.T) {
135 t.Parallel()

Callers

nothing calls this directly

Calls 5

floatPtrFunction · 0.85
convertFunction · 0.85
RunMethod · 0.65
ErrorMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected