github.com/kubeshop/testkube@v1.17.23/pkg/helm/chart_test.go (about) 1 package helm 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 "gopkg.in/yaml.v2" 8 ) 9 10 var chartContent = []byte(` 11 apiVersion: v2 12 name: testkube 13 description: A Helm chart for testkube. 14 15 # A chart can be either an 'application' or a 'library' chart. 16 # 17 # Application charts are a collection of templates that can be packaged into versioned archives 18 # to be deployed. 19 # 20 # Library charts provide useful utilities or functions for the chart developer. They're included as 21 # a dependency of application charts to inject those utilities and functions into the rendering 22 # pipeline. Library charts do not define any templates and therefore cannot be deployed. 23 type: application 24 25 # This is the chart version. This version number should be incremented each time you make changes 26 # to the chart and its templates, including the app version. 27 # Versions are expected to follow Semantic Versioning (https://semver.org/) 28 version: 0.5.17 29 30 dependencies: 31 - name: testkube-operator 32 version: "0.5.7" 33 repository: "https://kubeshop.github.io/helm-charts" 34 35 - name: mongodb 36 version: "10.0.0" 37 repository: "https://charts.bitnami.com/bitnami" 38 39 - name: testkube-api 40 version: "0.5.8" 41 repository: "https://kubeshop.github.io/helm-charts" 42 43 - name: postman-executor 44 version: "0.5.7" 45 repository: https://kubeshop.github.io/helm-charts 46 condition: postman-executor.enabled 47 48 - name: cypress-executor 49 version: "0.5.9" 50 repository: https://kubeshop.github.io/helm-charts 51 condition: cypress-executor.enabled 52 53 - name: curl-executor 54 version: "0.5.5" 55 repository: https://kubeshop.github.io/helm-charts 56 condition: curl-executor.enabled 57 `) 58 59 func TestGetDependencies(t *testing.T) { 60 61 var chart HelmChart 62 err := yaml.Unmarshal(chartContent, &chart) 63 assert.NoError(t, err) 64 65 t.Run("test GetDependencyVersion", func(t *testing.T) { 66 version, err := GetDependencyVersion(chart, "testkube-api") 67 assert.NoError(t, err) 68 assert.Equal(t, "0.5.8", version) 69 70 }) 71 72 t.Run("test UpdateDependencyVersion", func(t *testing.T) { 73 chart, err := UpdateDependencyVersion(chart, "testkube-api", "1.2.3") 74 assert.NoError(t, err) 75 version, err := GetDependencyVersion(chart, "testkube-api") 76 assert.NoError(t, err) 77 assert.Equal(t, "1.2.3", version) 78 79 }) 80 }