| 160 | } |
| 161 | |
| 162 | func TestUpdateSparsePatch(t *testing.T) { |
| 163 | file := providers.File{Endpoints: map[string]providers.Endpoint{ |
| 164 | "alpha": {Endpoint: "https://a", APIKeyEnv: "OLD", Description: "old"}, |
| 165 | }} |
| 166 | patch := providers.Patch{ |
| 167 | APIKeyEnv: ptr("NEW"), |
| 168 | Description: ptr("brand new"), |
| 169 | } |
| 170 | if err := providers.Update(&file, "alpha", patch); err != nil { |
| 171 | t.Fatalf("Update err = %v", err) |
| 172 | } |
| 173 | got := file.Endpoints["alpha"] |
| 174 | if got.Endpoint != "https://a" { |
| 175 | t.Fatalf("Endpoint changed unexpectedly: %q", got.Endpoint) |
| 176 | } |
| 177 | if got.APIKeyEnv != "NEW" { |
| 178 | t.Fatalf("APIKeyEnv = %q, want NEW", got.APIKeyEnv) |
| 179 | } |
| 180 | if got.Description != "brand new" { |
| 181 | t.Fatalf("Description = %q", got.Description) |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | func TestUpdateListOpsForClients(t *testing.T) { |
| 186 | file := providers.File{Endpoints: map[string]providers.Endpoint{ |