chore: add tests for .Release.ChartVersion
Signed-off-by: Simske <mail@simske.com>
This commit is contained in:
parent
06a4c903e9
commit
24f3bee113
|
|
@ -32,8 +32,8 @@ func TestHelmState_executeTemplates(t *testing.T) {
|
||||||
Version: "{{ .Release.Name }}-0.1",
|
Version: "{{ .Release.Name }}-0.1",
|
||||||
Name: "test-app",
|
Name: "test-app",
|
||||||
Namespace: "test-namespace-{{ .Release.Name }}",
|
Namespace: "test-namespace-{{ .Release.Name }}",
|
||||||
ValuesTemplate: []any{"config/{{ .Environment.Name }}/{{ .Release.Name }}/values.yaml"},
|
ValuesTemplate: []any{"config/{{ .Environment.Name }}/{{ .Release.Name }}/{{ .Release.ChartVersion }}/values.yaml"},
|
||||||
Secrets: []any{"config/{{ .Environment.Name }}/{{ .Release.Name }}/secrets.yaml"},
|
Secrets: []any{"config/{{ .Environment.Name }}/{{ .Release.Name }}/{{ .Release.ChartVersion }}/secrets.yaml"},
|
||||||
Labels: map[string]string{"id": "{{ .Release.Name }}"},
|
Labels: map[string]string{"id": "{{ .Release.Name }}"},
|
||||||
},
|
},
|
||||||
want: ReleaseSpec{
|
want: ReleaseSpec{
|
||||||
|
|
@ -41,8 +41,8 @@ func TestHelmState_executeTemplates(t *testing.T) {
|
||||||
Version: "test-app-0.1",
|
Version: "test-app-0.1",
|
||||||
Name: "test-app",
|
Name: "test-app",
|
||||||
Namespace: "test-namespace-test-app",
|
Namespace: "test-namespace-test-app",
|
||||||
Values: []any{"config/test_env/test-app/values.yaml"},
|
Values: []any{"config/test_env/test-app/test-app-0.1/values.yaml"},
|
||||||
Secrets: []any{"config/test_env/test-app/secrets.yaml"},
|
Secrets: []any{"config/test_env/test-app/test-app-0.1/secrets.yaml"},
|
||||||
Labels: map[string]string{"id": "test-app"},
|
Labels: map[string]string{"id": "test-app"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -89,20 +89,24 @@ func TestHelmState_executeTemplates(t *testing.T) {
|
||||||
Chart: "test-charts/chart",
|
Chart: "test-charts/chart",
|
||||||
Name: "test-app",
|
Name: "test-app",
|
||||||
Namespace: "dev",
|
Namespace: "dev",
|
||||||
|
Version: "1.5",
|
||||||
SetValuesTemplate: []SetValue{
|
SetValuesTemplate: []SetValue{
|
||||||
{Name: "val1", Value: "{{ .Release.Name }}-val1"},
|
{Name: "val1", Value: "{{ .Release.Name }}-val1"},
|
||||||
{Name: "val2", File: "{{ .Release.Name }}.yml"},
|
{Name: "val2", File: "{{ .Release.Name }}.yml"},
|
||||||
{Name: "val3", Values: []string{"{{ .Release.Name }}-val2", "{{ .Release.Name }}-val3"}},
|
{Name: "val3", Values: []string{"{{ .Release.Name }}-val2", "{{ .Release.Name }}-val3"}},
|
||||||
|
{Name: "val4", Value: "{{ .Release.Chart }}-{{ .Release.ChartVersion}}"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
want: ReleaseSpec{
|
want: ReleaseSpec{
|
||||||
Chart: "test-charts/chart",
|
Chart: "test-charts/chart",
|
||||||
Name: "test-app",
|
Name: "test-app",
|
||||||
Namespace: "dev",
|
Namespace: "dev",
|
||||||
|
Version: "1.5",
|
||||||
SetValues: []SetValue{
|
SetValues: []SetValue{
|
||||||
{Name: "val1", Value: "test-app-val1"},
|
{Name: "val1", Value: "test-app-val1"},
|
||||||
{Name: "val2", File: "test-app.yml"},
|
{Name: "val2", File: "test-app.yml"},
|
||||||
{Name: "val3", Values: []string{"test-app-val2", "test-app-val3"}},
|
{Name: "val3", Values: []string{"test-app-val2", "test-app-val3"}},
|
||||||
|
{Name: "val4", Value: "test-charts/chart-1.5"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -146,6 +150,19 @@ func TestHelmState_executeTemplates(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "Version is empty but used in templates (render as empty string)",
|
||||||
|
input: ReleaseSpec{
|
||||||
|
Name: "test-app",
|
||||||
|
Chart: "test-charts/{{ .Release.Name }}",
|
||||||
|
ValuesTemplate: []any{"config/values-{{ .Release.ChartVersion }}.yaml"},
|
||||||
|
},
|
||||||
|
want: ReleaseSpec{
|
||||||
|
Name: "test-app",
|
||||||
|
Chart: "test-charts/test-app",
|
||||||
|
Values: []any{"config/values-.yaml"},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := range tests {
|
for i := range tests {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue