Last active
March 12, 2020 08:00
-
-
Save developer-guy/361f36571c39a22f65500495acdd63e0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package helm | |
import ( | |
"github.com/gruntwork-io/terratest/modules/helm" | |
"github.com/stretchr/testify/suite" | |
coreV1 "k8s.io/api/core/v1" | |
"testing" | |
) | |
type HelmRenderingSuite struct { | |
suite.Suite | |
} | |
func (s *HelmRenderingSuite) TestPodTemplateRendersContainerImage() { | |
helmChartPath := "./charts/minimal-pod" | |
options := &helm.Options{ | |
SetValues: map[string]string{ | |
"image": "nginx:1.15.8", | |
}, | |
} | |
output := helm.RenderTemplate(s.T(), options, helmChartPath, "nginx", []string{"templates/pod.yaml"}) | |
var pod coreV1.Pod | |
helm.UnmarshalK8SYaml(s.T(), output, &pod) | |
expectedContainerImage := "nginx:1.15.8" | |
podFirstContainerImage := pod.Spec.Containers[0].Image | |
if expectedContainerImage != podFirstContainerImage { | |
s.T().Fatalf("Rendered container image (%s) is not expected (%s)", podFirstContainerImage, expectedContainerImage) | |
} | |
} | |
func TestHelmRenderingSuite(t *testing.T) { | |
suite.Run(t, new(HelmRenderingSuite)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment