(t *testing.T)
| 506 | } |
| 507 | |
| 508 | func TestLoadValues(t *testing.T) { |
| 509 | testCases := map[string]struct { |
| 510 | data []byte |
| 511 | expctedValues map[string]any |
| 512 | }{ |
| 513 | "It should load values correctly": { |
| 514 | data: []byte(` |
| 515 | foo: |
| 516 | image: foo:v1 |
| 517 | bar: |
| 518 | version: v2 |
| 519 | `), |
| 520 | expctedValues: map[string]any{ |
| 521 | "foo": map[string]any{ |
| 522 | "image": "foo:v1", |
| 523 | }, |
| 524 | "bar": map[string]any{ |
| 525 | "version": "v2", |
| 526 | }, |
| 527 | }, |
| 528 | }, |
| 529 | "It should load values correctly with multiple documents in one file": { |
| 530 | data: []byte(` |
| 531 | foo: |
| 532 | image: foo:v1 |
| 533 | bar: |
| 534 | version: v2 |
| 535 | --- |
| 536 | foo: |
| 537 | image: foo:v2 |
| 538 | `), |
| 539 | expctedValues: map[string]any{ |
| 540 | "foo": map[string]any{ |
| 541 | "image": "foo:v2", |
| 542 | }, |
| 543 | "bar": map[string]any{ |
| 544 | "version": "v2", |
| 545 | }, |
| 546 | }, |
| 547 | }, |
| 548 | } |
| 549 | for testName, testCase := range testCases { |
| 550 | t.Run(testName, func(tt *testing.T) { |
| 551 | values, err := LoadValues(bytes.NewReader(testCase.data)) |
| 552 | if err != nil { |
| 553 | tt.Fatal(err) |
| 554 | } |
| 555 | if !reflect.DeepEqual(values, testCase.expctedValues) { |
| 556 | tt.Errorf("Expected values: %v, got %v", testCase.expctedValues, values) |
| 557 | } |
| 558 | }) |
| 559 | } |
| 560 | } |
| 561 | |
| 562 | func TestMergeValuesV2(t *testing.T) { |
| 563 | nestedMap := map[string]any{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…