(t *testing.T)
| 274 | } |
| 275 | |
| 276 | func TestExtractExtraDocuments(t *testing.T) { |
| 277 | tests := []struct { |
| 278 | name string |
| 279 | patches []string |
| 280 | wantTalos int |
| 281 | wantExtra int |
| 282 | wantErr bool |
| 283 | }{ |
| 284 | { |
| 285 | name: "talos config with UserVolumeConfig as second document", |
| 286 | patches: []string{"machine:\n type: worker\ncluster:\n name: test\n---\napiVersion: v1alpha1\nkind: UserVolumeConfig\nname: databig"}, |
| 287 | wantTalos: 1, |
| 288 | wantExtra: 1, |
| 289 | }, |
| 290 | { |
| 291 | name: "only talos config", |
| 292 | patches: []string{"machine:\n type: worker"}, |
| 293 | wantTalos: 1, |
| 294 | wantExtra: 0, |
| 295 | }, |
| 296 | { |
| 297 | name: "only extra document", |
| 298 | patches: []string{"apiVersion: v1alpha1\nkind: UserVolumeConfig\nname: test"}, |
| 299 | wantTalos: 0, |
| 300 | wantExtra: 1, |
| 301 | }, |
| 302 | { |
| 303 | name: "multiple extra documents", |
| 304 | patches: []string{"machine:\n type: worker\n---\napiVersion: v1alpha1\nkind: UserVolumeConfig\nname: vol1\n---\napiVersion: v1alpha1\nkind: SideroLinkConfig\napiUrl: https://example.com"}, |
| 305 | wantTalos: 1, |
| 306 | wantExtra: 2, |
| 307 | }, |
| 308 | { |
| 309 | name: "empty patch", |
| 310 | patches: []string{""}, |
| 311 | wantTalos: 0, |
| 312 | wantExtra: 0, |
| 313 | }, |
| 314 | { |
| 315 | name: "multiple patches with mixed content", |
| 316 | patches: []string{"machine:\n type: controlplane", "cluster:\n name: prod"}, |
| 317 | wantTalos: 2, |
| 318 | wantExtra: 0, |
| 319 | }, |
| 320 | { |
| 321 | name: "CRLF line endings", |
| 322 | patches: []string{"machine:\r\n type: worker\r\n---\r\napiVersion: v1alpha1\r\nkind: UserVolumeConfig"}, |
| 323 | wantTalos: 1, |
| 324 | wantExtra: 1, |
| 325 | }, |
| 326 | { |
| 327 | name: "v1.12 multi-doc: talos patch + network and registry documents", |
| 328 | patches: []string{"machine:\n type: worker\ncluster:\n name: test\n---\napiVersion: v1alpha1\nkind: HostnameConfig\nhostname: worker-1\n---\napiVersion: v1alpha1\nkind: LinkConfig\nname: enp0s3\naddresses:\n - address: 192.168.1.100/24\n---\napiVersion: v1alpha1\nkind: RegistryMirrorConfig\nname: docker.io\nendpoints:\n - url: https://mirror.gcr.io"}, |
| 329 | wantTalos: 1, |
| 330 | wantExtra: 3, |
| 331 | }, |
| 332 | { |
| 333 | name: "v1.12 multi-doc: talos patch + bond, vlan, vip documents", |
nothing calls this directly
no test coverage detected