chore: update common test dependencies (#949)

This commit is contained in:
Kjeld Schouten-Lebbing 2021-09-09 20:39:33 +02:00 committed by GitHub
parent 07dd78b2a7
commit 9d218b36f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 34 additions and 34 deletions

View File

@ -41,14 +41,14 @@ func (suite *ContainerTestSuite) TestCommand() {
deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test") deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test")
suite.Assertions.NotEmpty(deploymentManifest) suite.Assertions.NotEmpty(deploymentManifest)
containers, _ := deploymentManifest.Path("spec.template.spec.containers").Children() containers := deploymentManifest.Path("spec.template.spec.containers").Children()
containerCommand := containers[0].Path("command") containerCommand := containers[0].Path("command")
if tc.expectedCommand == nil { if tc.expectedCommand == nil {
suite.Assertions.Empty(containerCommand) suite.Assertions.Empty(containerCommand)
} else { } else {
var actualDataList []string var actualDataList []string
actualData, _ := containerCommand.Children() actualData := containerCommand.Children()
for _, key := range actualData { for _, key := range actualData {
actualDataList = append(actualDataList, key.Data().(string)) actualDataList = append(actualDataList, key.Data().(string))
} }
@ -76,14 +76,14 @@ func (suite *ContainerTestSuite) TestArgs() {
deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test") deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test")
suite.Assertions.NotEmpty(deploymentManifest) suite.Assertions.NotEmpty(deploymentManifest)
containers, _ := deploymentManifest.Path("spec.template.spec.containers").Children() containers := deploymentManifest.Path("spec.template.spec.containers").Children()
containerArgs := containers[0].Path("args") containerArgs := containers[0].Path("args")
if tc.expectedArgs == nil { if tc.expectedArgs == nil {
suite.Assertions.Empty(containerArgs) suite.Assertions.Empty(containerArgs)
} else { } else {
var actualDataList []string var actualDataList []string
actualData, _ := containerArgs.Children() actualData := containerArgs.Children()
for _, key := range actualData { for _, key := range actualData {
actualDataList = append(actualDataList, key.Data().(string)) actualDataList = append(actualDataList, key.Data().(string))
} }
@ -130,16 +130,16 @@ func (suite *ContainerTestSuite) TestEnv() {
deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test") deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test")
suite.Assertions.NotEmpty(deploymentManifest) suite.Assertions.NotEmpty(deploymentManifest)
containers, _ := deploymentManifest.Path("spec.template.spec.containers").Children() containers := deploymentManifest.Path("spec.template.spec.containers").Children()
containerEnv := containers[0].Path("env") containerEnv := containers[0].Path("env")
if tc.expectedEnv == nil { if tc.expectedEnv == nil {
suite.Assertions.Empty(containerEnv) suite.Assertions.Empty(containerEnv)
} else { } else {
actualDataMap := make(map[string]string) actualDataMap := make(map[string]string)
actualData, _ := containerEnv.Children() actualData := containerEnv.Children()
for _, value := range actualData { for _, value := range actualData {
envVar, _ := value.ChildrenMap() envVar := value.ChildrenMap()
envName := envVar["name"].Data().(string) envName := envVar["name"].Data().(string)
var envValue string var envValue string
if _, ok := envVar["valueFrom"]; ok { if _, ok := envVar["valueFrom"]; ok {
@ -181,8 +181,8 @@ func (suite *ContainerTestSuite) TestEnvFrom() {
deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test") deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test")
suite.Assertions.NotEmpty(deploymentManifest) suite.Assertions.NotEmpty(deploymentManifest)
containers, _ := deploymentManifest.Path("spec.template.spec.containers").Children() containers := deploymentManifest.Path("spec.template.spec.containers").Children()
containerEnvFrom, _ := containers[0].Path("envFrom").Children() containerEnvFrom := containers[0].Path("envFrom").Children()
if !tc.expectSecret { if !tc.expectSecret {
suite.Assertions.Empty(containerEnvFrom) suite.Assertions.Empty(containerEnvFrom)
@ -215,8 +215,8 @@ func (suite *ContainerTestSuite) TestPorts() {
deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test") deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test")
suite.Assertions.NotEmpty(deploymentManifest) suite.Assertions.NotEmpty(deploymentManifest)
containers, _ := deploymentManifest.Path("spec.template.spec.containers").Children() containers := deploymentManifest.Path("spec.template.spec.containers").Children()
containerPorts, _ := containers[0].Path("ports").Children() containerPorts := containers[0].Path("ports").Children()
suite.Assertions.NotEmpty(containerPorts[0]) suite.Assertions.NotEmpty(containerPorts[0])
suite.Assertions.EqualValues(tc.expectedPortName, containerPorts[0].Path("name").Data()) suite.Assertions.EqualValues(tc.expectedPortName, containerPorts[0].Path("name").Data())
suite.Assertions.EqualValues(tc.expectedProtocol, containerPorts[0].Path("protocol").Data()) suite.Assertions.EqualValues(tc.expectedProtocol, containerPorts[0].Path("protocol").Data())
@ -280,8 +280,8 @@ func (suite *ContainerTestSuite) TestPersistenceVolumeMounts() {
deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test") deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test")
suite.Assertions.NotEmpty(deploymentManifest) suite.Assertions.NotEmpty(deploymentManifest)
containers, _ := deploymentManifest.Path("spec.template.spec.containers").Children() containers := deploymentManifest.Path("spec.template.spec.containers").Children()
containerVolumeMounts, _ := containers[0].Path("volumeMounts").Children() containerVolumeMounts := containers[0].Path("volumeMounts").Children()
suite.Assertions.NotEmpty(containerVolumeMounts) suite.Assertions.NotEmpty(containerVolumeMounts)
for _, volumeMount := range containerVolumeMounts { for _, volumeMount := range containerVolumeMounts {

View File

@ -94,7 +94,7 @@ func (suite *HorizontalPodAutoscalerTestSuite) TestMetrics() {
manifest := suite.Chart.Manifests.Get("HorizontalPodAutoscaler", "common-test") manifest := suite.Chart.Manifests.Get("HorizontalPodAutoscaler", "common-test")
suite.Assertions.NotEmpty(manifest) suite.Assertions.NotEmpty(manifest)
manifestMetrics, _ := manifest.Path("spec.metrics").Children() manifestMetrics := manifest.Path("spec.metrics").Children()
metricsMap := make(map[string]int) metricsMap := make(map[string]int)
for _, manifestMetric := range manifestMetrics { for _, manifestMetric := range manifestMetrics {

View File

@ -85,13 +85,13 @@ func (suite *IngressTestSuite) TestValues() {
if tc.expectedIngress { if tc.expectedIngress {
suite.Assertions.NotEmpty(ingressManifest) suite.Assertions.NotEmpty(ingressManifest)
ingressRules, _ := ingressManifest.Path("spec.rules").Children() ingressRules := ingressManifest.Path("spec.rules").Children()
if tc.expectedHostName != "" { if tc.expectedHostName != "" {
suite.Assertions.EqualValues(tc.expectedHostName, ingressRules[0].Path("host").Data()) suite.Assertions.EqualValues(tc.expectedHostName, ingressRules[0].Path("host").Data())
} }
if tc.expectedPath != "" { if tc.expectedPath != "" {
paths, _ := ingressRules[0].Path("http.paths").Children() paths := ingressRules[0].Path("http.paths").Children()
suite.Assertions.EqualValues(tc.expectedPath, paths[0].Path("path").Data()) suite.Assertions.EqualValues(tc.expectedPath, paths[0].Path("path").Data())
} }
} else { } else {
@ -134,8 +134,8 @@ func (suite *IngressTestSuite) TestPathServices() {
ingressManifest := suite.Chart.Manifests.Get("Ingress", "common-test") ingressManifest := suite.Chart.Manifests.Get("Ingress", "common-test")
suite.Assertions.NotEmpty(ingressManifest) suite.Assertions.NotEmpty(ingressManifest)
ingressRules, _ := ingressManifest.Path("spec.rules").Children() ingressRules := ingressManifest.Path("spec.rules").Children()
paths, _ := ingressRules[0].Path("http.paths").Children() paths := ingressRules[0].Path("http.paths").Children()
primaryPath := paths[0] primaryPath := paths[0]
if tc.expectedServiceName == "" { if tc.expectedServiceName == "" {
@ -205,8 +205,8 @@ func (suite *IngressTestSuite) TestTLS() {
if tc.expectedTLS { if tc.expectedTLS {
suite.Assertions.NotEmpty(ingressManifest.Path("spec.tls").Data()) suite.Assertions.NotEmpty(ingressManifest.Path("spec.tls").Data())
tlsSpec, _ := ingressManifest.Path("spec.tls").Children() tlsSpec := ingressManifest.Path("spec.tls").Children()
tlsHostsSpec, _ := tlsSpec[0].Path("hosts").Children() tlsHostsSpec := tlsSpec[0].Path("hosts").Children()
suite.Assertions.EqualValues(tc.expectedHostName, tlsHostsSpec[0].Data()) suite.Assertions.EqualValues(tc.expectedHostName, tlsHostsSpec[0].Data())
if tc.expectedSecretName == "" { if tc.expectedSecretName == "" {

View File

@ -109,7 +109,7 @@ func (suite *PodTestSuite) TestAdditionalContainers() {
deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test") deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test")
containers := deploymentManifest.Path("spec.template.spec.containers") containers := deploymentManifest.Path("spec.template.spec.containers")
suite.Assertions.Contains(containers.Search("name").Data(), tc.expectedContainer) suite.Assertions.Contains(containers.Search("*", "name").Data(), tc.expectedContainer)
}) })
} }
} }
@ -155,7 +155,7 @@ func (suite *PodTestSuite) TestPersistenceItems() {
suite.Assertions.EqualValues(nil, volumes.Data()) suite.Assertions.EqualValues(nil, volumes.Data())
} else { } else {
suite.Assertions.NotEmpty(volumes) suite.Assertions.NotEmpty(volumes)
searchVolumes := volumes.Search("name").Data() searchVolumes := volumes.Search("*", "name").Data()
for _, expectedVolume := range tc.expectedVolumes { for _, expectedVolume := range tc.expectedVolumes {
suite.Assertions.Contains(searchVolumes, expectedVolume) suite.Assertions.Contains(searchVolumes, expectedVolume)
} }
@ -201,7 +201,7 @@ func (suite *PodTestSuite) TestPersistenceClaimNames() {
} }
deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test") deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test")
volumes, _ := deploymentManifest.Path("spec.template.spec.volumes").Children() volumes := deploymentManifest.Path("spec.template.spec.volumes").Children()
for _, volume := range volumes { for _, volume := range volumes {
volumeName := volume.Path("name").Data().(string) volumeName := volume.Path("name").Data().(string)
@ -238,7 +238,7 @@ func (suite *PodTestSuite) TestPersistenceEmptyDir() {
} }
deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test") deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test")
volumes, _ := deploymentManifest.Path("spec.template.spec.volumes").Children() volumes := deploymentManifest.Path("spec.template.spec.volumes").Children()
volume := volumes[0] volume := volumes[0]
suite.Assertions.NotEmpty(volume.Data()) suite.Assertions.NotEmpty(volume.Data())
@ -294,7 +294,7 @@ func (suite *PodTestSuite) TestHostPathVolumes() {
suite.Assertions.EqualValues(nil, volumes.Data()) suite.Assertions.EqualValues(nil, volumes.Data())
} else { } else {
suite.Assertions.NotEmpty(volumes) suite.Assertions.NotEmpty(volumes)
searchVolumes := volumes.Search("name").Data() searchVolumes := volumes.Search("*", "name").Data()
for _, expectedVolume := range tc.expectedVolumes { for _, expectedVolume := range tc.expectedVolumes {
suite.Assertions.Contains(searchVolumes, expectedVolume) suite.Assertions.Contains(searchVolumes, expectedVolume)
} }
@ -330,7 +330,7 @@ func (suite *PodTestSuite) TestVolumeClaimTemplates() {
controllerManifest := suite.Chart.Manifests.Get("StatefulSet", "common-test") controllerManifest := suite.Chart.Manifests.Get("StatefulSet", "common-test")
suite.Assertions.NotEmpty(controllerManifest) suite.Assertions.NotEmpty(controllerManifest)
volumeClaimTemplates, _ := controllerManifest.Path("spec.volumeClaimTemplates").Children() volumeClaimTemplates := controllerManifest.Path("spec.volumeClaimTemplates").Children()
suite.Assertions.NotEmpty(volumeClaimTemplates) suite.Assertions.NotEmpty(volumeClaimTemplates)
for _, volumeClaimTemplate := range volumeClaimTemplates { for _, volumeClaimTemplate := range volumeClaimTemplates {
@ -339,7 +339,7 @@ func (suite *PodTestSuite) TestVolumeClaimTemplates() {
if tc.expectedAccessMode == "" { if tc.expectedAccessMode == "" {
suite.Assertions.Empty(controllerManifest) suite.Assertions.Empty(controllerManifest)
} else { } else {
accessModes, _ := volumeClaimTemplate.Path("spec.accessModes").Children() accessModes := volumeClaimTemplate.Path("spec.accessModes").Children()
suite.Assertions.EqualValues(tc.expectedAccessMode, accessModes[0].Data()) suite.Assertions.EqualValues(tc.expectedAccessMode, accessModes[0].Data())
} }

View File

@ -69,7 +69,7 @@ func (suite *ServiceTestSuite) TestPortNames() {
serviceManifest := suite.Chart.Manifests.Get("Service", "common-test") serviceManifest := suite.Chart.Manifests.Get("Service", "common-test")
suite.Assertions.NotEmpty(serviceManifest) suite.Assertions.NotEmpty(serviceManifest)
servicePorts, _ := serviceManifest.Path("spec.ports").Children() servicePorts := serviceManifest.Path("spec.ports").Children()
suite.Assertions.EqualValues(tc.expectedName, servicePorts[0].Path("name").Data()) suite.Assertions.EqualValues(tc.expectedName, servicePorts[0].Path("name").Data())
suite.Assertions.EqualValues(tc.expectedTargetPort, servicePorts[0].Path("targetPort").Data()) suite.Assertions.EqualValues(tc.expectedTargetPort, servicePorts[0].Path("targetPort").Data())
}) })
@ -96,7 +96,7 @@ func (suite *ServiceTestSuite) TestPortProtocol() {
serviceManifest := suite.Chart.Manifests.Get("Service", "common-test") serviceManifest := suite.Chart.Manifests.Get("Service", "common-test")
suite.Assertions.NotEmpty(serviceManifest) suite.Assertions.NotEmpty(serviceManifest)
servicePorts, _ := serviceManifest.Path("spec.ports").Children() servicePorts := serviceManifest.Path("spec.ports").Children()
suite.Assertions.EqualValues(tc.expectedProtocol, servicePorts[0].Path("protocol").Data()) suite.Assertions.EqualValues(tc.expectedProtocol, servicePorts[0].Path("protocol").Data())
}) })
} }

2
go.mod
View File

@ -3,7 +3,7 @@ module github.com/truecharts/apps
go 1.16 go 1.16
require ( require (
github.com/Jeffail/gabs v1.4.0 github.com/Jeffail/gabs/v2 v2.6.1
github.com/stretchr/testify v1.7.0 github.com/stretchr/testify v1.7.0
helm.sh/helm/v3 v3.6.1 helm.sh/helm/v3 v3.6.1
sigs.k8s.io/yaml v1.2.0 sigs.k8s.io/yaml v1.2.0

4
go.sum
View File

@ -39,8 +39,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
github.com/Jeffail/gabs v1.4.0 h1://5fYRRTq1edjfIrQGvdkcd22pkYUrHZ5YC/H2GJVAo= github.com/Jeffail/gabs/v2 v2.6.1 h1:wwbE6nTQTwIMsMxzi6XFQQYRZ6wDc1mSdxoAN+9U4Gk=
github.com/Jeffail/gabs v1.4.0/go.mod h1:6xMvQMK4k33lb7GUUpaAPh6nKMmemQeg5d4gn7/bOXc= github.com/Jeffail/gabs/v2 v2.6.1/go.mod h1:xCn81vdHKxFUuWWAaD5jCTQDNPBMh5pPs9IJ+NcziBI=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/MakeNowJust/heredoc v0.0.0-20170808103936-bb23615498cd h1:sjQovDkwrZp8u+gxLtPgKGjk5hCxuy2hrRejBTA9xFU= github.com/MakeNowJust/heredoc v0.0.0-20170808103936-bb23615498cd h1:sjQovDkwrZp8u+gxLtPgKGjk5hCxuy2hrRejBTA9xFU=
github.com/MakeNowJust/heredoc v0.0.0-20170808103936-bb23615498cd/go.mod h1:64YHyfSL2R96J44Nlwm39UHepQbyR5q10x7iYa1ks2E= github.com/MakeNowJust/heredoc v0.0.0-20170808103936-bb23615498cd/go.mod h1:64YHyfSL2R96J44Nlwm39UHepQbyR5q10x7iYa1ks2E=

View File

@ -4,7 +4,7 @@ import (
"errors" "errors"
"strings" "strings"
"github.com/Jeffail/gabs" "github.com/Jeffail/gabs/v2"
) )
type manifestCollection map[string]map[string]gabs.Container type manifestCollection map[string]map[string]gabs.Container

View File

@ -1,7 +1,7 @@
package helmunit package helmunit
import ( import (
"github.com/Jeffail/gabs" "github.com/Jeffail/gabs/v2"
"sigs.k8s.io/yaml" "sigs.k8s.io/yaml"
) )