(t *testing.T)
| 453 | } |
| 454 | |
| 455 | func TestLoadValues(t *testing.T) { |
| 456 | testCases := map[string]struct { |
| 457 | data []byte |
| 458 | expctedValues map[string]any |
| 459 | }{ |
| 460 | "It should load values correctly": { |
| 461 | data: []byte(` |
| 462 | foo: |
| 463 | image: foo:v1 |
| 464 | bar: |
| 465 | version: v2 |
| 466 | `), |
| 467 | expctedValues: map[string]any{ |
| 468 | "foo": map[string]any{ |
| 469 | "image": "foo:v1", |
| 470 | }, |
| 471 | "bar": map[string]any{ |
| 472 | "version": "v2", |
| 473 | }, |
| 474 | }, |
| 475 | }, |
| 476 | "It should load values correctly with multiple documents in one file": { |
| 477 | data: []byte(` |
| 478 | foo: |
| 479 | image: foo:v1 |
| 480 | bar: |
| 481 | version: v2 |
| 482 | --- |
| 483 | foo: |
| 484 | image: foo:v2 |
| 485 | `), |
| 486 | expctedValues: map[string]any{ |
| 487 | "foo": map[string]any{ |
| 488 | "image": "foo:v2", |
| 489 | }, |
| 490 | "bar": map[string]any{ |
| 491 | "version": "v2", |
| 492 | }, |
| 493 | }, |
| 494 | }, |
| 495 | } |
| 496 | for testName, testCase := range testCases { |
| 497 | t.Run(testName, func(tt *testing.T) { |
| 498 | values, err := LoadValues(bytes.NewReader(testCase.data)) |
| 499 | if err != nil { |
| 500 | tt.Fatal(err) |
| 501 | } |
| 502 | if !reflect.DeepEqual(values, testCase.expctedValues) { |
| 503 | tt.Errorf("Expected values: %v, got %v", testCase.expctedValues, values) |
| 504 | } |
| 505 | }) |
| 506 | } |
| 507 | } |
| 508 | |
| 509 | func TestMergeValuesV3(t *testing.T) { |
| 510 | nestedMap := map[string]any{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…