Avoid repetitions
This commit is contained in:
@@ -27,7 +27,7 @@ services:
|
||||
output := _compile_test(t, "-s", "templates/web/configmap.yaml")
|
||||
configMap := v1.ConfigMap{}
|
||||
if err := yaml.Unmarshal([]byte(output), &configMap); err != nil {
|
||||
t.Errorf("Failed to unmarshal the output: %s", err)
|
||||
t.Errorf(unmarshalError, err)
|
||||
}
|
||||
data := configMap.Data
|
||||
if len(data) != 2 {
|
||||
|
@@ -26,7 +26,7 @@ services:
|
||||
// dt := DeploymentTest{}
|
||||
dt := v1.Deployment{}
|
||||
if err := yaml.Unmarshal([]byte(output), &dt); err != nil {
|
||||
t.Errorf("Failed to unmarshal the output: %s", err)
|
||||
t.Errorf(unmarshalError, err)
|
||||
}
|
||||
|
||||
if *dt.Spec.Replicas != 1 {
|
||||
|
@@ -33,7 +33,7 @@ services:
|
||||
output := _compile_test(t, "-s", "templates/web/ingress.yaml", "--set", "web.ingress.enabled=true")
|
||||
ingress := v1.Ingress{}
|
||||
if err := yaml.Unmarshal([]byte(output), &ingress); err != nil {
|
||||
t.Errorf("Failed to unmarshal the output: %s", err)
|
||||
t.Errorf(unmarshalError, err)
|
||||
}
|
||||
if len(ingress.Spec.Rules) != 1 {
|
||||
t.Errorf("Expected 1 rule, got %d", len(ingress.Spec.Rules))
|
||||
|
@@ -32,7 +32,7 @@ services:
|
||||
output := _compile_test(t, "-s", "templates/web/secret.yaml")
|
||||
secret := v1.Secret{}
|
||||
if err := yaml.Unmarshal([]byte(output), &secret); err != nil {
|
||||
t.Errorf("Failed to unmarshal the output: %s", err)
|
||||
t.Errorf(unmarshalError, err)
|
||||
}
|
||||
data := secret.Data
|
||||
if len(data) != 1 {
|
||||
|
@@ -27,7 +27,7 @@ services:
|
||||
output := _compile_test(t, "-s", "templates/web/service.yaml")
|
||||
service := v1.Service{}
|
||||
if err := yaml.Unmarshal([]byte(output), &service); err != nil {
|
||||
t.Errorf("Failed to unmarshal the output: %s", err)
|
||||
t.Errorf(unmarshalError, err)
|
||||
}
|
||||
|
||||
if len(service.Spec.Ports) != 2 {
|
||||
|
@@ -9,6 +9,8 @@ import (
|
||||
"katenary/parser"
|
||||
)
|
||||
|
||||
const unmarshalError = "Failed to unmarshal the output: %s"
|
||||
|
||||
func setup(content string) string {
|
||||
// write the _compose_file in temporary directory
|
||||
tmpDir, err := os.MkdirTemp("", "katenary")
|
||||
|
@@ -31,7 +31,7 @@ volumes:
|
||||
|
||||
dt := v1.Deployment{}
|
||||
if err := yaml.Unmarshal([]byte(output), &dt); err != nil {
|
||||
t.Errorf("Failed to unmarshal the output: %s", err)
|
||||
t.Errorf(unmarshalError, err)
|
||||
}
|
||||
|
||||
if dt.Spec.Template.Spec.Containers[0].VolumeMounts[0].Name != "data" {
|
||||
@@ -71,7 +71,7 @@ services:
|
||||
output := _compile_test(t, "-s", "templates/web/deployment.yaml")
|
||||
dt := v1.Deployment{}
|
||||
if err := yaml.Unmarshal([]byte(output), &dt); err != nil {
|
||||
t.Errorf("Failed to unmarshal the output: %s", err)
|
||||
t.Errorf(unmarshalError, err)
|
||||
}
|
||||
// get the volume mount path
|
||||
volumeMountPath := dt.Spec.Template.Spec.Containers[0].VolumeMounts[0].MountPath
|
||||
@@ -88,7 +88,7 @@ services:
|
||||
}
|
||||
configMap := corev1.ConfigMap{}
|
||||
if err := yaml.Unmarshal([]byte(output), &configMap); err != nil {
|
||||
t.Errorf("Failed to unmarshal the output: %s", err)
|
||||
t.Errorf(unmarshalError, err)
|
||||
}
|
||||
data := configMap.Data
|
||||
if len(data) != 1 {
|
||||
|
Reference in New Issue
Block a user