@ -435,6 +435,8 @@ func TestRenderNestedValues(t *testing.T) {
// Ensure namespacing rules are working.
deepestpath := "templates/inner.tpl"
checkrelease := "templates/release.tpl"
// Ensure subcharts scopes are working.
subchartspath := "templates/subcharts.tpl"
deepest := & chart . Chart {
Metadata : & chart . Metadata { Name : "deepest" } ,
@ -442,7 +444,7 @@ func TestRenderNestedValues(t *testing.T) {
{ Name : deepestpath , Data : [ ] byte ( ` And this same {{ .Values .what }} that smiles {{ .Values .global .when }} ` ) } ,
{ Name : checkrelease , Data : [ ] byte ( ` Tomorrow will be {{ default "happy" .Release .Name }} ` ) } ,
} ,
Values : map [ string ] interface { } { "what" : "milkshake" },
Values : map [ string ] interface { } { "what" : "milkshake" , "where" : "here" },
}
inner := & chart . Chart {
@ -450,7 +452,7 @@ func TestRenderNestedValues(t *testing.T) {
Templates : [ ] * chart . File {
{ Name : innerpath , Data : [ ] byte ( ` Old {{ .Values .who }} is still a-flyin' ` ) } ,
} ,
Values : map [ string ] interface { } { "who" : "Robert" },
Values : map [ string ] interface { } { "who" : "Robert" , "what" : "glasses" },
}
inner . AddDependency ( deepest )
@ -458,12 +460,14 @@ func TestRenderNestedValues(t *testing.T) {
Metadata : & chart . Metadata { Name : "top" } ,
Templates : [ ] * chart . File {
{ Name : outerpath , Data : [ ] byte ( ` Gather ye {{ .Values .what }} while ye may ` ) } ,
{ Name : subchartspath , Data : [ ] byte ( ` The glorious Lamp of {{ .Subcharts .herrick .Subcharts .deepest .Values .where }} , the {{ .Subcharts .herrick .Values .what }} ` ) } ,
} ,
Values : map [ string ] interface { } {
"what" : "stinkweed" ,
"who" : "me" ,
"herrick" : map [ string ] interface { } {
"who" : "time" ,
"who" : "time" ,
"what" : "Sun" ,
} ,
} ,
}
@ -473,7 +477,8 @@ func TestRenderNestedValues(t *testing.T) {
"what" : "rosebuds" ,
"herrick" : map [ string ] interface { } {
"deepest" : map [ string ] interface { } {
"what" : "flower" ,
"what" : "flower" ,
"where" : "Heaven" ,
} ,
} ,
"global" : map [ string ] interface { } {
@ -520,6 +525,11 @@ func TestRenderNestedValues(t *testing.T) {
if out [ fullcheckrelease ] != "Tomorrow will be dyin" {
t . Errorf ( "Unexpected release: %q" , out [ fullcheckrelease ] )
}
fullchecksubcharts := "top/" + subchartspath
if out [ fullchecksubcharts ] != "The glorious Lamp of Heaven, the Sun" {
t . Errorf ( "Unexpected subcharts: %q" , out [ fullchecksubcharts ] )
}
}
func TestRenderBuiltinValues ( t * testing . T ) {
@ -539,6 +549,7 @@ func TestRenderBuiltinValues(t *testing.T) {
Metadata : & chart . Metadata { Name : "Troy" } ,
Templates : [ ] * chart . File {
{ Name : "templates/Aeneas" , Data : [ ] byte ( ` {{ .Template .Name }} {{ .Chart .Name }} {{ .Release .Name }} ` ) } ,
{ Name : "templates/Amata" , Data : [ ] byte ( ` {{ .Subcharts .Latium .Chart .Name }} {{ .Subcharts .Latium .Files .author | printf "%s" }} ` ) } ,
} ,
}
outer . AddDependency ( inner )
@ -561,6 +572,7 @@ func TestRenderBuiltinValues(t *testing.T) {
expects := map [ string ] string {
"Troy/charts/Latium/templates/Lavinia" : "Troy/charts/Latium/templates/LaviniaLatiumAeneid" ,
"Troy/templates/Aeneas" : "Troy/templates/AeneasTroyAeneid" ,
"Troy/templates/Amata" : "Latium Virgil" ,
"Troy/charts/Latium/templates/From" : "Virgil Aeneid" ,
}
for file , expect := range expects {