quintush / helm-unittest

BDD styled unit test framework for Kubernetes Helm charts as a Helm plugin.
MIT License
345 stars 69 forks source link

Chart Name is not change-able #169

Open jkamenik opened 2 years ago

jkamenik commented 2 years ago

An edge case, but one that comes up more then it should is the need to change the Chart name. This can cause issues if {{ .Chart.Name }} is used in an immutable part of the spec.

What should happen?

The .Chart.Name value should be override-able so that we can test various upgrade scenarios including cases where the chart name had to change.

What happens

You cannot override the chart version.

Example

An ideal test case is something like the following:

# This test has to be setup in a specific way to actually work the way we think.
# 1) delete the existing `__snapshot__/deployment-immutable-fields_test.yaml`
# 2) comment out the test `release` and `chart` section
# 3) regen the first release snapshot by running `helm unittest -3 -f tests/deployment-immutable-fields_test.yaml msv-ripper`
suite: immutable fields have not been changed on deployments

# This are the things that change during an upgrade.  Set to an initial value
release:
  name: immutable
  namespace: "ripper"
  revision: 0
  isUpgrade: false
capabilities:
  majorVersion: 1
  minorVersion: 22
chart:
  name: foo
  version: 0.0.9
  appVersion: 0.0.9

templates:
  # List all the deployment fields here
  - "amqp-deployment.yaml"

tests:
  - it: should not have the spec.selector
    values:
      - ../values.yaml
    asserts:
      - matchSnapshot:
          # This is the field to capture, that cannot change
          path: spec.selector

    # The below are the items that can change in a given release.
    # Comment this out if re-generating the test snapshot file.
    release:
      name: new-release
      revision: 1
      isUpgrade: true
    capabilities:
      majorVersion: 1
      minorVersion: 24
    chart:
      name: ripper
      version: 1.0.0
      appVersion: 1.0.0