test(values): add map-env and exchange volumes tests

This commit is contained in:
2024-11-22 16:23:00 +01:00
parent 8aee6d9983
commit 827b5bc830
2 changed files with 90 additions and 0 deletions

View File

@@ -1,6 +1,8 @@
package generator
import (
"fmt"
"katenary/generator/labels"
"os"
"testing"
@@ -40,3 +42,34 @@ services:
t.Errorf("Expected BAR to be baz, got %s", data["BAR"])
}
}
func TestMapEnv(t *testing.T) {
composeFile := `
services:
web:
image: nginx:1.29
environment:
FOO: bar
labels:
%[1]s/map-env: |-
FOO: 'baz'
`
composeFile = fmt.Sprintf(composeFile, labels.KatenaryLabelPrefix)
tmpDir := setup(composeFile)
defer teardown(tmpDir)
currentDir, _ := os.Getwd()
os.Chdir(tmpDir)
defer os.Chdir(currentDir)
output := internalCompileTest(t, "-s", "templates/web/configmap.yaml")
configMap := v1.ConfigMap{}
if err := yaml.Unmarshal([]byte(output), &configMap); err != nil {
t.Errorf(unmarshalError, err)
}
data := configMap.Data
if v, ok := data["FOO"]; !ok || v != "baz" {
t.Errorf("Expected FOO to be baz, got %s", v)
}
}