(t *testing.T)
| 765 | } |
| 766 | |
| 767 | func TestRenderBuiltinValues(t *testing.T) { |
| 768 | modTime := time.Now() |
| 769 | inner := &chart.Chart{ |
| 770 | Metadata: &chart.Metadata{Name: "Latium", APIVersion: chart.APIVersionV2}, |
| 771 | Templates: []*common.File{ |
| 772 | {Name: "templates/Lavinia", ModTime: modTime, Data: []byte(`{{.Template.Name}}{{.Chart.Name}}{{.Release.Name}}`)}, |
| 773 | {Name: "templates/From", ModTime: modTime, Data: []byte(`{{.Files.author | printf "%s"}} {{.Files.Get "book/title.txt"}}`)}, |
| 774 | }, |
| 775 | Files: []*common.File{ |
| 776 | {Name: "author", ModTime: modTime, Data: []byte("Virgil")}, |
| 777 | {Name: "book/title.txt", ModTime: modTime, Data: []byte("Aeneid")}, |
| 778 | }, |
| 779 | } |
| 780 | |
| 781 | outer := &chart.Chart{ |
| 782 | Metadata: &chart.Metadata{Name: "Troy", APIVersion: chart.APIVersionV2}, |
| 783 | Templates: []*common.File{ |
| 784 | {Name: "templates/Aeneas", ModTime: modTime, Data: []byte(`{{.Template.Name}}{{.Chart.Name}}{{.Release.Name}}`)}, |
| 785 | {Name: "templates/Amata", ModTime: modTime, Data: []byte(`{{.Subcharts.Latium.Chart.Name}} {{.Subcharts.Latium.Files.author | printf "%s"}}`)}, |
| 786 | }, |
| 787 | } |
| 788 | outer.AddDependency(inner) |
| 789 | |
| 790 | inject := common.Values{ |
| 791 | "Values": "", |
| 792 | "Chart": outer.Metadata, |
| 793 | "Release": common.Values{ |
| 794 | "Name": "Aeneid", |
| 795 | }, |
| 796 | } |
| 797 | |
| 798 | t.Logf("Calculated values: %v", outer) |
| 799 | |
| 800 | out, err := Render(outer, inject) |
| 801 | if err != nil { |
| 802 | t.Fatalf("failed to render templates: %s", err) |
| 803 | } |
| 804 | |
| 805 | expects := map[string]string{ |
| 806 | "Troy/charts/Latium/templates/Lavinia": "Troy/charts/Latium/templates/LaviniaLatiumAeneid", |
| 807 | "Troy/templates/Aeneas": "Troy/templates/AeneasTroyAeneid", |
| 808 | "Troy/templates/Amata": "Latium Virgil", |
| 809 | "Troy/charts/Latium/templates/From": "Virgil Aeneid", |
| 810 | } |
| 811 | for file, expect := range expects { |
| 812 | if out[file] != expect { |
| 813 | t.Errorf("Expected %q, got %q", expect, out[file]) |
| 814 | } |
| 815 | } |
| 816 | |
| 817 | } |
| 818 | |
| 819 | func TestAlterFuncMap_include(t *testing.T) { |
| 820 | modTime := time.Now() |
nothing calls this directly
no test coverage detected
searching dependent graphs…