Skip to content

Commit

Permalink
fix(k8s-metacollector/tests): update tests to reflect latest changes
Browse files Browse the repository at this point in the history
Signed-off-by: Aldo Lacuku <[email protected]>
  • Loading branch information
alacuku authored and poiana committed Jan 2, 2024
1 parent 6dbdad4 commit 6369df8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions charts/k8s-metacollector/tests/unit/chartInfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import (
"testing"
)

func chartInfo(t *testing.T, chartPath string) (map[string]string, error) {
func chartInfo(t *testing.T, chartPath string) (map[string]interface{}, error) {
// Get chart info.
output, err := helm.RunHelmCommandAndGetOutputE(t, &helm.Options{}, "show", "chart", chartPath)
if err != nil {
return nil, err
}
chartInfo := map[string]string{}
chartInfo := map[string]interface{}{}
err = yaml.Unmarshal([]byte(output), &chartInfo)
return chartInfo, err
}
6 changes: 4 additions & 2 deletions charts/k8s-metacollector/tests/unit/commonMetaFields_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,19 @@ func (s *commonMetaFieldsTest) TestLabels() {
// Get app version.
appVersion, found := cInfo["appVersion"]
s.True(found, "should find app version in chart info")
appVersion = appVersion.(string)
// Get chart version.
chartVersion, found := cInfo["version"]
s.True(found, "should find chart version in chart info")
// Get chart name.
chartName, found := cInfo["name"]
s.True(found, "should find chart name in chart info")
chartName = chartName.(string)
expectedLabels := map[string]string{
"helm.sh/chart": fmt.Sprintf("%s-%s", chartName, chartVersion),
"app.kubernetes.io/name": chartName,
"app.kubernetes.io/name": chartName.(string),
"app.kubernetes.io/instance": s.releaseName,
"app.kubernetes.io/version": appVersion,
"app.kubernetes.io/version": appVersion.(string),
"app.kubernetes.io/managed-by": "Helm",
"app.kubernetes.io/component": "metadata-collector",
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ func (s *deploymentTemplateTest) TestImage() {
map[string]string{
"image.repository": "falcosecurity/testingRepository",
},
"docker.io/falcosecurity/testingRepository:0.0.0",
fmt.Sprintf("docker.io/falcosecurity/testingRepository:%s", appVersion),
},
{
"changingImageRegistry",
map[string]string{
"image.registry": "ghcr.io",
},
"ghcr.io/falcosecurity/k8s-metacollector:0.0.0",
fmt.Sprintf("ghcr.io/falcosecurity/k8s-metacollector:%s", appVersion),
},
{
"changingAllImageFields",
Expand Down

0 comments on commit 6369df8

Please sign in to comment.