chore: update common test dependencies (#949)
This commit is contained in:
parent
07dd78b2a7
commit
9d218b36f4
|
@ -41,14 +41,14 @@ func (suite *ContainerTestSuite) TestCommand() {
|
|||
|
||||
deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test")
|
||||
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")
|
||||
|
||||
if tc.expectedCommand == nil {
|
||||
suite.Assertions.Empty(containerCommand)
|
||||
} else {
|
||||
var actualDataList []string
|
||||
actualData, _ := containerCommand.Children()
|
||||
actualData := containerCommand.Children()
|
||||
for _, key := range actualData {
|
||||
actualDataList = append(actualDataList, key.Data().(string))
|
||||
}
|
||||
|
@ -76,14 +76,14 @@ func (suite *ContainerTestSuite) TestArgs() {
|
|||
|
||||
deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test")
|
||||
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")
|
||||
|
||||
if tc.expectedArgs == nil {
|
||||
suite.Assertions.Empty(containerArgs)
|
||||
} else {
|
||||
var actualDataList []string
|
||||
actualData, _ := containerArgs.Children()
|
||||
actualData := containerArgs.Children()
|
||||
for _, key := range actualData {
|
||||
actualDataList = append(actualDataList, key.Data().(string))
|
||||
}
|
||||
|
@ -130,16 +130,16 @@ func (suite *ContainerTestSuite) TestEnv() {
|
|||
|
||||
deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test")
|
||||
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")
|
||||
|
||||
if tc.expectedEnv == nil {
|
||||
suite.Assertions.Empty(containerEnv)
|
||||
} else {
|
||||
actualDataMap := make(map[string]string)
|
||||
actualData, _ := containerEnv.Children()
|
||||
actualData := containerEnv.Children()
|
||||
for _, value := range actualData {
|
||||
envVar, _ := value.ChildrenMap()
|
||||
envVar := value.ChildrenMap()
|
||||
envName := envVar["name"].Data().(string)
|
||||
var envValue string
|
||||
if _, ok := envVar["valueFrom"]; ok {
|
||||
|
@ -181,8 +181,8 @@ func (suite *ContainerTestSuite) TestEnvFrom() {
|
|||
deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test")
|
||||
suite.Assertions.NotEmpty(deploymentManifest)
|
||||
|
||||
containers, _ := deploymentManifest.Path("spec.template.spec.containers").Children()
|
||||
containerEnvFrom, _ := containers[0].Path("envFrom").Children()
|
||||
containers := deploymentManifest.Path("spec.template.spec.containers").Children()
|
||||
containerEnvFrom := containers[0].Path("envFrom").Children()
|
||||
|
||||
if !tc.expectSecret {
|
||||
suite.Assertions.Empty(containerEnvFrom)
|
||||
|
@ -215,8 +215,8 @@ func (suite *ContainerTestSuite) TestPorts() {
|
|||
|
||||
deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test")
|
||||
suite.Assertions.NotEmpty(deploymentManifest)
|
||||
containers, _ := deploymentManifest.Path("spec.template.spec.containers").Children()
|
||||
containerPorts, _ := containers[0].Path("ports").Children()
|
||||
containers := deploymentManifest.Path("spec.template.spec.containers").Children()
|
||||
containerPorts := containers[0].Path("ports").Children()
|
||||
suite.Assertions.NotEmpty(containerPorts[0])
|
||||
suite.Assertions.EqualValues(tc.expectedPortName, containerPorts[0].Path("name").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")
|
||||
suite.Assertions.NotEmpty(deploymentManifest)
|
||||
containers, _ := deploymentManifest.Path("spec.template.spec.containers").Children()
|
||||
containerVolumeMounts, _ := containers[0].Path("volumeMounts").Children()
|
||||
containers := deploymentManifest.Path("spec.template.spec.containers").Children()
|
||||
containerVolumeMounts := containers[0].Path("volumeMounts").Children()
|
||||
suite.Assertions.NotEmpty(containerVolumeMounts)
|
||||
|
||||
for _, volumeMount := range containerVolumeMounts {
|
||||
|
|
|
@ -94,7 +94,7 @@ func (suite *HorizontalPodAutoscalerTestSuite) TestMetrics() {
|
|||
manifest := suite.Chart.Manifests.Get("HorizontalPodAutoscaler", "common-test")
|
||||
suite.Assertions.NotEmpty(manifest)
|
||||
|
||||
manifestMetrics, _ := manifest.Path("spec.metrics").Children()
|
||||
manifestMetrics := manifest.Path("spec.metrics").Children()
|
||||
|
||||
metricsMap := make(map[string]int)
|
||||
for _, manifestMetric := range manifestMetrics {
|
||||
|
|
|
@ -85,13 +85,13 @@ func (suite *IngressTestSuite) TestValues() {
|
|||
if tc.expectedIngress {
|
||||
suite.Assertions.NotEmpty(ingressManifest)
|
||||
|
||||
ingressRules, _ := ingressManifest.Path("spec.rules").Children()
|
||||
ingressRules := ingressManifest.Path("spec.rules").Children()
|
||||
if tc.expectedHostName != "" {
|
||||
suite.Assertions.EqualValues(tc.expectedHostName, ingressRules[0].Path("host").Data())
|
||||
}
|
||||
|
||||
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())
|
||||
}
|
||||
} else {
|
||||
|
@ -134,8 +134,8 @@ func (suite *IngressTestSuite) TestPathServices() {
|
|||
ingressManifest := suite.Chart.Manifests.Get("Ingress", "common-test")
|
||||
suite.Assertions.NotEmpty(ingressManifest)
|
||||
|
||||
ingressRules, _ := ingressManifest.Path("spec.rules").Children()
|
||||
paths, _ := ingressRules[0].Path("http.paths").Children()
|
||||
ingressRules := ingressManifest.Path("spec.rules").Children()
|
||||
paths := ingressRules[0].Path("http.paths").Children()
|
||||
primaryPath := paths[0]
|
||||
|
||||
if tc.expectedServiceName == "" {
|
||||
|
@ -205,8 +205,8 @@ func (suite *IngressTestSuite) TestTLS() {
|
|||
|
||||
if tc.expectedTLS {
|
||||
suite.Assertions.NotEmpty(ingressManifest.Path("spec.tls").Data())
|
||||
tlsSpec, _ := ingressManifest.Path("spec.tls").Children()
|
||||
tlsHostsSpec, _ := tlsSpec[0].Path("hosts").Children()
|
||||
tlsSpec := ingressManifest.Path("spec.tls").Children()
|
||||
tlsHostsSpec := tlsSpec[0].Path("hosts").Children()
|
||||
suite.Assertions.EqualValues(tc.expectedHostName, tlsHostsSpec[0].Data())
|
||||
|
||||
if tc.expectedSecretName == "" {
|
||||
|
|
|
@ -109,7 +109,7 @@ func (suite *PodTestSuite) TestAdditionalContainers() {
|
|||
|
||||
deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test")
|
||||
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())
|
||||
} else {
|
||||
suite.Assertions.NotEmpty(volumes)
|
||||
searchVolumes := volumes.Search("name").Data()
|
||||
searchVolumes := volumes.Search("*", "name").Data()
|
||||
for _, expectedVolume := range tc.expectedVolumes {
|
||||
suite.Assertions.Contains(searchVolumes, expectedVolume)
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ func (suite *PodTestSuite) TestPersistenceClaimNames() {
|
|||
}
|
||||
|
||||
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 {
|
||||
volumeName := volume.Path("name").Data().(string)
|
||||
|
@ -238,7 +238,7 @@ func (suite *PodTestSuite) TestPersistenceEmptyDir() {
|
|||
}
|
||||
|
||||
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]
|
||||
suite.Assertions.NotEmpty(volume.Data())
|
||||
|
||||
|
@ -294,7 +294,7 @@ func (suite *PodTestSuite) TestHostPathVolumes() {
|
|||
suite.Assertions.EqualValues(nil, volumes.Data())
|
||||
} else {
|
||||
suite.Assertions.NotEmpty(volumes)
|
||||
searchVolumes := volumes.Search("name").Data()
|
||||
searchVolumes := volumes.Search("*", "name").Data()
|
||||
for _, expectedVolume := range tc.expectedVolumes {
|
||||
suite.Assertions.Contains(searchVolumes, expectedVolume)
|
||||
}
|
||||
|
@ -330,7 +330,7 @@ func (suite *PodTestSuite) TestVolumeClaimTemplates() {
|
|||
controllerManifest := suite.Chart.Manifests.Get("StatefulSet", "common-test")
|
||||
suite.Assertions.NotEmpty(controllerManifest)
|
||||
|
||||
volumeClaimTemplates, _ := controllerManifest.Path("spec.volumeClaimTemplates").Children()
|
||||
volumeClaimTemplates := controllerManifest.Path("spec.volumeClaimTemplates").Children()
|
||||
suite.Assertions.NotEmpty(volumeClaimTemplates)
|
||||
|
||||
for _, volumeClaimTemplate := range volumeClaimTemplates {
|
||||
|
@ -339,7 +339,7 @@ func (suite *PodTestSuite) TestVolumeClaimTemplates() {
|
|||
if tc.expectedAccessMode == "" {
|
||||
suite.Assertions.Empty(controllerManifest)
|
||||
} else {
|
||||
accessModes, _ := volumeClaimTemplate.Path("spec.accessModes").Children()
|
||||
accessModes := volumeClaimTemplate.Path("spec.accessModes").Children()
|
||||
suite.Assertions.EqualValues(tc.expectedAccessMode, accessModes[0].Data())
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ func (suite *ServiceTestSuite) TestPortNames() {
|
|||
|
||||
serviceManifest := suite.Chart.Manifests.Get("Service", "common-test")
|
||||
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.expectedTargetPort, servicePorts[0].Path("targetPort").Data())
|
||||
})
|
||||
|
@ -96,7 +96,7 @@ func (suite *ServiceTestSuite) TestPortProtocol() {
|
|||
|
||||
serviceManifest := suite.Chart.Manifests.Get("Service", "common-test")
|
||||
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())
|
||||
})
|
||||
}
|
||||
|
|
2
go.mod
2
go.mod
|
@ -3,7 +3,7 @@ module github.com/truecharts/apps
|
|||
go 1.16
|
||||
|
||||
require (
|
||||
github.com/Jeffail/gabs v1.4.0
|
||||
github.com/Jeffail/gabs/v2 v2.6.1
|
||||
github.com/stretchr/testify v1.7.0
|
||||
helm.sh/helm/v3 v3.6.1
|
||||
sigs.k8s.io/yaml v1.2.0
|
||||
|
|
4
go.sum
4
go.sum
|
@ -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/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/Jeffail/gabs v1.4.0 h1://5fYRRTq1edjfIrQGvdkcd22pkYUrHZ5YC/H2GJVAo=
|
||||
github.com/Jeffail/gabs v1.4.0/go.mod h1:6xMvQMK4k33lb7GUUpaAPh6nKMmemQeg5d4gn7/bOXc=
|
||||
github.com/Jeffail/gabs/v2 v2.6.1 h1:wwbE6nTQTwIMsMxzi6XFQQYRZ6wDc1mSdxoAN+9U4Gk=
|
||||
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/MakeNowJust/heredoc v0.0.0-20170808103936-bb23615498cd h1:sjQovDkwrZp8u+gxLtPgKGjk5hCxuy2hrRejBTA9xFU=
|
||||
github.com/MakeNowJust/heredoc v0.0.0-20170808103936-bb23615498cd/go.mod h1:64YHyfSL2R96J44Nlwm39UHepQbyR5q10x7iYa1ks2E=
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/Jeffail/gabs"
|
||||
"github.com/Jeffail/gabs/v2"
|
||||
)
|
||||
|
||||
type manifestCollection map[string]map[string]gabs.Container
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package helmunit
|
||||
|
||||
import (
|
||||
"github.com/Jeffail/gabs"
|
||||
"github.com/Jeffail/gabs/v2"
|
||||
"sigs.k8s.io/yaml"
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue