package generator import ( "os" "testing" v1 "k8s.io/api/apps/v1" "sigs.k8s.io/yaml" ) func TestGenerate(t *testing.T) { _compose_file := ` services: web: image: nginx:1.29 ` tmpDir := setup(_compose_file) defer teardown(tmpDir) currentDir, _ := os.Getwd() os.Chdir(tmpDir) defer os.Chdir(currentDir) output := _compile_test(t, "-s", "templates/web/deployment.yaml") // dt := DeploymentTest{} dt := v1.Deployment{} if err := yaml.Unmarshal([]byte(output), &dt); err != nil { t.Errorf(unmarshalError, err) } if *dt.Spec.Replicas != 1 { t.Errorf("Expected replicas to be 1, got %d", dt.Spec.Replicas) t.Errorf("Output: %s", output) } if dt.Spec.Template.Spec.Containers[0].Image != "nginx:1.29" { t.Errorf("Expected image to be nginx:1.29, got %s", dt.Spec.Template.Spec.Containers[0].Image) } }