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)
| 101 | // exists but its Models map is empty. Both should fail loud so we never |
| 102 | // ship a partial seed. |
| 103 | func 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 | |
| 134 | func TestValidate(t *testing.T) { |
| 135 | t.Parallel() |