Skip to content

Commit

Permalink
Merge pull request helm-unittest#420 from helm-unittest/bugfix/AllowE…
Browse files Browse the repository at this point in the history
…mptyObjectsInKubernetesProvider

Bugfix/allow empty objects in kubernetes provider
  • Loading branch information
quintush authored Sep 23, 2024
2 parents 4e27252 + b7576b9 commit 6f06220
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
==================
- Fix assertion does not match when using camelcase function (resolves #359)
- Fix templating multi document Helm file with trims break YAML parsing (resolves #403)
- Fix lookup of resources defined in kubernetesProvider without any objects (resolves #380)

0.6.1 / 2024-09-01
==================
Expand Down
8 changes: 5 additions & 3 deletions pkg/unittest/.snapshots/TestV3RunnerOkWithFakeK8sClient
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
### Chart [ with-k8s-fake-client ] ../../test/data/v3/with-k8s-fake-client


PASS ../../test/data/v3/with-k8s-fake-client/tests/lookup_crd_noprovider_test.yaml
PASS ../../test/data/v3/with-k8s-fake-client/tests/lookup_crd_test.yaml
PASS ../../test/data/v3/with-k8s-fake-client/tests/lookup_noprovider_test.yaml
PASS ../../test/data/v3/with-k8s-fake-client/tests/lookup_test.yaml


Charts: 1 passed, 1 total
Test Suites: 2 passed, 2 total
Tests: 2 passed, 2 total
Snapshot: 2 passed, 2 total
Test Suites: 4 passed, 4 total
Tests: 4 passed, 4 total
Snapshot: 4 passed, 4 total
Time: XX.XXXms


8 changes: 6 additions & 2 deletions pkg/unittest/test_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,13 @@ func (t *TestJob) renderV3Chart(targetChart *v3chart.Chart, userValues []byte) (
// Filter the files that needs to be validated
filteredChart := CopyV3Chart(t.chartRoute, targetChart.Name(), t.defaultTemplatesToAssert, targetChart)

outputOfFiles, err := v3engine.RenderWithClientProvider(filteredChart, vals, &t.KubernetesProvider)
var outputOfFiles map[string]string

// Correct output.
if len(t.KubernetesProvider.Objects) > 0 {
outputOfFiles, err = v3engine.RenderWithClientProvider(filteredChart, vals, &t.KubernetesProvider)
} else {
outputOfFiles, err = v3engine.Render(filteredChart, vals)
}

var renderSucceed bool
outputOfFiles, renderSucceed, err = t.translateErrorToOutputFiles(err, outputOfFiles)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
manifest should match snapshot:
1: |
backup_exists: {}
backup_not_exists: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
manifest should match snapshot:
1: |
ingress_exists: {}
ingress_not_exists: {}
namespace_exists: {}
namespace_not_exists: {}
namespaces: {}
pod_exists: {}
pod_not_exists: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
templates:
- templates/lookup_crd.yaml
tests:
- it: manifest should match snapshot
asserts:
- matchSnapshot: {}
- isNullOrEmpty:
path: backup_exists
- isNullOrEmpty:
path: backup_not_exists
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
templates:
- templates/lookup.yaml
tests:
- it: manifest should match snapshot
asserts:
- matchSnapshot: {}
- isNullOrEmpty:
path: pod_exists
- isNullOrEmpty:
path: ingress_exists
- isNullOrEmpty:
path: namespace_exists
- isNullOrEmpty:
path: pod_not_exists
- isNullOrEmpty:
path: ingress_not_exists
- isNullOrEmpty:
path: namespace_not_exists

0 comments on commit 6f06220

Please sign in to comment.