From 6369df82987ef87045cb2e511565912f187d69f2 Mon Sep 17 00:00:00 2001 From: Aldo Lacuku Date: Fri, 22 Dec 2023 14:46:45 +0100 Subject: [PATCH] fix(k8s-metacollector/tests): update tests to reflect latest changes Signed-off-by: Aldo Lacuku --- charts/k8s-metacollector/tests/unit/chartInfo.go | 4 ++-- .../k8s-metacollector/tests/unit/commonMetaFields_test.go | 6 ++++-- .../k8s-metacollector/tests/unit/deploymentTemplate_test.go | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/charts/k8s-metacollector/tests/unit/chartInfo.go b/charts/k8s-metacollector/tests/unit/chartInfo.go index 8f518ace3..33aaed2bb 100644 --- a/charts/k8s-metacollector/tests/unit/chartInfo.go +++ b/charts/k8s-metacollector/tests/unit/chartInfo.go @@ -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 } diff --git a/charts/k8s-metacollector/tests/unit/commonMetaFields_test.go b/charts/k8s-metacollector/tests/unit/commonMetaFields_test.go index 385033d42..7d5352d39 100644 --- a/charts/k8s-metacollector/tests/unit/commonMetaFields_test.go +++ b/charts/k8s-metacollector/tests/unit/commonMetaFields_test.go @@ -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", } diff --git a/charts/k8s-metacollector/tests/unit/deploymentTemplate_test.go b/charts/k8s-metacollector/tests/unit/deploymentTemplate_test.go index 8c4ca0db3..3e9cc235b 100644 --- a/charts/k8s-metacollector/tests/unit/deploymentTemplate_test.go +++ b/charts/k8s-metacollector/tests/unit/deploymentTemplate_test.go @@ -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",