From eeacda2a259058f3fc758b8ab2a4b11195e687d7 Mon Sep 17 00:00:00 2001 From: Markus Pesch Date: Sat, 3 Oct 2026 22:19:39 +0200 Subject: [PATCH] test: align the file names of the helm unit tests with the chart conventions The chart conventions demand camelCase file names, forbid short names like `svc` and require the unit tests to mirror the template structure. The unit tests followed none of that consistently. Four casings existed side by side - camelCase (extraInitContainers.yaml), kebab-case (checksum-annotations.yaml), a snake and kebab mix (init_directory_structure.sh-rootless.yaml) and all caps (HA.yaml) - so there was no pattern to copy when adding a suite, which is how the inconsistency kept growing. Three groups of problems are fixed: - svc-configuration.yaml used exactly the short name the conventions forbid for files and keys. - Several file names repeated their own directory, for example deployment/deployment-additional-config.yaml and metric-secret/metrics-secret-servicemonitor-disabled.yaml, which names the subject three times. The directory already carries that information, so the file name now only carries the scenario. The default scenario of a template is named basics.yaml. - Four suites lived in a directory of a template they do not assert on. They were filed under deployment/ because the deployment is rendered as a side effect, not because it is the subject: deployment/deprecations.yaml -> deprecation/deployment.yaml deployment/inline-config.yaml -> config/inlineConfig.yaml deployment/storage-class-configuration.yaml -> persistentVolumeClaim/storageClass.yaml deployment/svc-configuration.yaml -> service/configuration.yaml storage-class-configuration.yaml is the clearest case: a persistentVolumeClaim directory already existed next to it. The suite titles of the two suites whose subject changed are adjusted accordingly. The Makefile passed `--file unittests/helm/values-conflicting-checks.yaml`, but that file does not exist in the tree. `helm unittest` ignores a missing path without a warning, so the flag has been dead for an unknown amount of time while still suggesting the checks run. It is removed; the `unittests/helm/**/*.yaml` glob would pick the file up anyway if it ever returns. The naming rule is written down in the copilot instructions, together with the constraint that the glob matches only a single directory level, so a suite can never be placed directly in unittests/helm/. All 49 suites and 267 tests still pass. Co-authored-by: Copilot --- .github/copilot-instructions.md | 3 ++- Makefile | 2 +- unittests/helm/admin-secret/{admin.yaml => basics.yaml} | 0 unittests/helm/config/{actions-config.yaml => actions.yaml} | 0 unittests/helm/config/{cache-config.yaml => cache.yaml} | 0 .../{config-environment-script.yaml => environmentScript.yaml} | 0 .../inline-config.yaml => config/inlineConfig.yaml} | 2 +- .../{metrics-section_metrics-token.yaml => metricsToken.yaml} | 0 unittests/helm/config/{queue-config.yaml => queue.yaml} | 0 .../config/{server-section_domain.yaml => serverDomain.yaml} | 0 unittests/helm/config/{session-config.yaml => session.yaml} | 0 ...y-postgresql.yaml => customizationIntegrityPostgresql.yaml} | 0 ...tgresql-ha.yaml => customizationIntegrityPostgresqlHA.yaml} | 0 ...integrity-valkey.yaml => customizationIntegrityValkey.yaml} | 0 .../{major-image-bump.yaml => majorImageBump.yaml} | 0 ...deployment-additional-config.yaml => additionalConfig.yaml} | 0 unittests/helm/deployment/{admin.yaml => adminUser.yaml} | 0 unittests/helm/deployment/{basic.yaml => basics.yaml} | 0 .../{checksum-annotations.yaml => checksumAnnotations.yaml} | 0 unittests/helm/deployment/{HA.yaml => highAvailability.yaml} | 0 .../{image-configuration.yaml => imageConfiguration.yaml} | 0 .../{sidecar-container.yaml => sidecarContainer.yaml} | 0 .../deployment/{signing-disabled.yaml => signingDisabled.yaml} | 0 .../deployment/{signing-enabled.yaml => signingEnabled.yaml} | 0 .../{ssh-configuration.yaml => sshConfiguration.yaml} | 0 .../deprecations.yaml => deprecation/deployment.yaml} | 0 .../gpg-secret/{signing-disabled.yaml => signingDisabled.yaml} | 0 .../gpg-secret/{signing-enabled.yaml => signingEnabled.yaml} | 0 unittests/helm/ingress/{ingress.yaml => basics.yaml} | 0 unittests/helm/init/{basic.yaml => basics.yaml} | 0 ...rectory_structure.sh.yaml => directoryStructureScript.yaml} | 0 ....sh-rootless.yaml => directoryStructureScriptRootless.yaml} | 0 ...et-servicemonitor-disabled.yaml => monitoringDisabled.yaml} | 0 ...cret-servicemonitor-enabled.yaml => monitoringEnabled.yaml} | 0 .../{persistentVolumeClaim.yaml => basics.yaml} | 0 .../storageClass.yaml} | 2 +- unittests/helm/route/{basic.yaml => basics.yaml} | 0 .../svc-configuration.yaml => service/configuration.yaml} | 0 .../helm/serviceAccount/{serviceAccount.yaml => basics.yaml} | 0 unittests/helm/servicemonitor/{basic.yaml => basics.yaml} | 0 .../{servicemonitor-disabled.yaml => monitoringDisabled.yaml} | 0 .../{servicemonitor-enabled.yaml => monitoringEnabled.yaml} | 0 42 files changed, 5 insertions(+), 4 deletions(-) rename unittests/helm/admin-secret/{admin.yaml => basics.yaml} (100%) rename unittests/helm/config/{actions-config.yaml => actions.yaml} (100%) rename unittests/helm/config/{cache-config.yaml => cache.yaml} (100%) rename unittests/helm/config/{config-environment-script.yaml => environmentScript.yaml} (100%) rename unittests/helm/{deployment/inline-config.yaml => config/inlineConfig.yaml} (97%) rename unittests/helm/config/{metrics-section_metrics-token.yaml => metricsToken.yaml} (100%) rename unittests/helm/config/{queue-config.yaml => queue.yaml} (100%) rename unittests/helm/config/{server-section_domain.yaml => serverDomain.yaml} (100%) rename unittests/helm/config/{session-config.yaml => session.yaml} (100%) rename unittests/helm/dependency-checks/{customization-integrity-postgresql.yaml => customizationIntegrityPostgresql.yaml} (100%) rename unittests/helm/dependency-checks/{customization-integrity-postgresql-ha.yaml => customizationIntegrityPostgresqlHA.yaml} (100%) rename unittests/helm/dependency-checks/{customization-integrity-valkey.yaml => customizationIntegrityValkey.yaml} (100%) rename unittests/helm/dependency-checks/{major-image-bump.yaml => majorImageBump.yaml} (100%) rename unittests/helm/deployment/{deployment-additional-config.yaml => additionalConfig.yaml} (100%) rename unittests/helm/deployment/{admin.yaml => adminUser.yaml} (100%) rename unittests/helm/deployment/{basic.yaml => basics.yaml} (100%) rename unittests/helm/deployment/{checksum-annotations.yaml => checksumAnnotations.yaml} (100%) rename unittests/helm/deployment/{HA.yaml => highAvailability.yaml} (100%) rename unittests/helm/deployment/{image-configuration.yaml => imageConfiguration.yaml} (100%) rename unittests/helm/deployment/{sidecar-container.yaml => sidecarContainer.yaml} (100%) rename unittests/helm/deployment/{signing-disabled.yaml => signingDisabled.yaml} (100%) rename unittests/helm/deployment/{signing-enabled.yaml => signingEnabled.yaml} (100%) rename unittests/helm/deployment/{ssh-configuration.yaml => sshConfiguration.yaml} (100%) rename unittests/helm/{deployment/deprecations.yaml => deprecation/deployment.yaml} (100%) rename unittests/helm/gpg-secret/{signing-disabled.yaml => signingDisabled.yaml} (100%) rename unittests/helm/gpg-secret/{signing-enabled.yaml => signingEnabled.yaml} (100%) rename unittests/helm/ingress/{ingress.yaml => basics.yaml} (100%) rename unittests/helm/init/{basic.yaml => basics.yaml} (100%) rename unittests/helm/init/{init_directory_structure.sh.yaml => directoryStructureScript.yaml} (100%) rename unittests/helm/init/{init_directory_structure.sh-rootless.yaml => directoryStructureScriptRootless.yaml} (100%) rename unittests/helm/metric-secret/{metrics-secret-servicemonitor-disabled.yaml => monitoringDisabled.yaml} (100%) rename unittests/helm/metric-secret/{metrics-secret-servicemonitor-enabled.yaml => monitoringEnabled.yaml} (100%) rename unittests/helm/persistentVolumeClaim/{persistentVolumeClaim.yaml => basics.yaml} (100%) rename unittests/helm/{deployment/storage-class-configuration.yaml => persistentVolumeClaim/storageClass.yaml} (89%) rename unittests/helm/route/{basic.yaml => basics.yaml} (100%) rename unittests/helm/{deployment/svc-configuration.yaml => service/configuration.yaml} (100%) rename unittests/helm/serviceAccount/{serviceAccount.yaml => basics.yaml} (100%) rename unittests/helm/servicemonitor/{basic.yaml => basics.yaml} (100%) rename unittests/helm/servicemonitor/{servicemonitor-disabled.yaml => monitoringDisabled.yaml} (100%) rename unittests/helm/servicemonitor/{servicemonitor-enabled.yaml => monitoringEnabled.yaml} (100%) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index e80892d..4fb3a90 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -52,8 +52,9 @@ data: ### Unit Tests -- Helm unit tests live in `unittests/helm/` mirroring the template structure. +- Helm unit tests live in `unittests/helm/` mirroring the template structure. A suite belongs into the directory of the template it asserts on, never into the directory of a template it only renders as a side effect. - Test files are YAML using the [helm-unittest](https://github.com/helm-unittest/helm-unittest) format. +- Name test files in camelCase after the scenario they cover (e.g. `signingEnabled.yaml`), use `basics.yaml` for the default scenario and do not repeat the directory name in the file name. The `make helm/unittest` glob only matches one directory level, so every suite must live in a subdirectory. - Each test must set all required values explicitly — do not rely on cross-test state. - The `values.yaml` file must pass `yamllint`. The configuration is in `.yamllint.yaml`. Use `make yamllint` to run the linter. - The title of the unit test should clearly describe the scenario being tested. As title must be use a short sentence starting with a capital letter and ending without a period. diff --git a/Makefile b/Makefile index 4298838..5c3972a 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,7 @@ helm/dependency-update: # ============================================================================== PHONY+=helm/unittest helm/unittest: - helm unittest --strict --file 'unittests/helm/**/*.yaml' --file 'unittests/helm/values-conflicting-checks.yaml' ./ + helm unittest --strict --file 'unittests/helm/**/*.yaml' ./ # BASH PREPARE # ============================================================================== diff --git a/unittests/helm/admin-secret/admin.yaml b/unittests/helm/admin-secret/basics.yaml similarity index 100% rename from unittests/helm/admin-secret/admin.yaml rename to unittests/helm/admin-secret/basics.yaml diff --git a/unittests/helm/config/actions-config.yaml b/unittests/helm/config/actions.yaml similarity index 100% rename from unittests/helm/config/actions-config.yaml rename to unittests/helm/config/actions.yaml diff --git a/unittests/helm/config/cache-config.yaml b/unittests/helm/config/cache.yaml similarity index 100% rename from unittests/helm/config/cache-config.yaml rename to unittests/helm/config/cache.yaml diff --git a/unittests/helm/config/config-environment-script.yaml b/unittests/helm/config/environmentScript.yaml similarity index 100% rename from unittests/helm/config/config-environment-script.yaml rename to unittests/helm/config/environmentScript.yaml diff --git a/unittests/helm/deployment/inline-config.yaml b/unittests/helm/config/inlineConfig.yaml similarity index 97% rename from unittests/helm/deployment/inline-config.yaml rename to unittests/helm/config/inlineConfig.yaml index ab9dd37..e9d2dd3 100644 --- a/unittests/helm/deployment/inline-config.yaml +++ b/unittests/helm/config/inlineConfig.yaml @@ -1,4 +1,4 @@ -suite: Test deployment inline config +suite: Test config inlineConfig release: name: gitea-unittests namespace: testing diff --git a/unittests/helm/config/metrics-section_metrics-token.yaml b/unittests/helm/config/metricsToken.yaml similarity index 100% rename from unittests/helm/config/metrics-section_metrics-token.yaml rename to unittests/helm/config/metricsToken.yaml diff --git a/unittests/helm/config/queue-config.yaml b/unittests/helm/config/queue.yaml similarity index 100% rename from unittests/helm/config/queue-config.yaml rename to unittests/helm/config/queue.yaml diff --git a/unittests/helm/config/server-section_domain.yaml b/unittests/helm/config/serverDomain.yaml similarity index 100% rename from unittests/helm/config/server-section_domain.yaml rename to unittests/helm/config/serverDomain.yaml diff --git a/unittests/helm/config/session-config.yaml b/unittests/helm/config/session.yaml similarity index 100% rename from unittests/helm/config/session-config.yaml rename to unittests/helm/config/session.yaml diff --git a/unittests/helm/dependency-checks/customization-integrity-postgresql.yaml b/unittests/helm/dependency-checks/customizationIntegrityPostgresql.yaml similarity index 100% rename from unittests/helm/dependency-checks/customization-integrity-postgresql.yaml rename to unittests/helm/dependency-checks/customizationIntegrityPostgresql.yaml diff --git a/unittests/helm/dependency-checks/customization-integrity-postgresql-ha.yaml b/unittests/helm/dependency-checks/customizationIntegrityPostgresqlHA.yaml similarity index 100% rename from unittests/helm/dependency-checks/customization-integrity-postgresql-ha.yaml rename to unittests/helm/dependency-checks/customizationIntegrityPostgresqlHA.yaml diff --git a/unittests/helm/dependency-checks/customization-integrity-valkey.yaml b/unittests/helm/dependency-checks/customizationIntegrityValkey.yaml similarity index 100% rename from unittests/helm/dependency-checks/customization-integrity-valkey.yaml rename to unittests/helm/dependency-checks/customizationIntegrityValkey.yaml diff --git a/unittests/helm/dependency-checks/major-image-bump.yaml b/unittests/helm/dependency-checks/majorImageBump.yaml similarity index 100% rename from unittests/helm/dependency-checks/major-image-bump.yaml rename to unittests/helm/dependency-checks/majorImageBump.yaml diff --git a/unittests/helm/deployment/deployment-additional-config.yaml b/unittests/helm/deployment/additionalConfig.yaml similarity index 100% rename from unittests/helm/deployment/deployment-additional-config.yaml rename to unittests/helm/deployment/additionalConfig.yaml diff --git a/unittests/helm/deployment/admin.yaml b/unittests/helm/deployment/adminUser.yaml similarity index 100% rename from unittests/helm/deployment/admin.yaml rename to unittests/helm/deployment/adminUser.yaml diff --git a/unittests/helm/deployment/basic.yaml b/unittests/helm/deployment/basics.yaml similarity index 100% rename from unittests/helm/deployment/basic.yaml rename to unittests/helm/deployment/basics.yaml diff --git a/unittests/helm/deployment/checksum-annotations.yaml b/unittests/helm/deployment/checksumAnnotations.yaml similarity index 100% rename from unittests/helm/deployment/checksum-annotations.yaml rename to unittests/helm/deployment/checksumAnnotations.yaml diff --git a/unittests/helm/deployment/HA.yaml b/unittests/helm/deployment/highAvailability.yaml similarity index 100% rename from unittests/helm/deployment/HA.yaml rename to unittests/helm/deployment/highAvailability.yaml diff --git a/unittests/helm/deployment/image-configuration.yaml b/unittests/helm/deployment/imageConfiguration.yaml similarity index 100% rename from unittests/helm/deployment/image-configuration.yaml rename to unittests/helm/deployment/imageConfiguration.yaml diff --git a/unittests/helm/deployment/sidecar-container.yaml b/unittests/helm/deployment/sidecarContainer.yaml similarity index 100% rename from unittests/helm/deployment/sidecar-container.yaml rename to unittests/helm/deployment/sidecarContainer.yaml diff --git a/unittests/helm/deployment/signing-disabled.yaml b/unittests/helm/deployment/signingDisabled.yaml similarity index 100% rename from unittests/helm/deployment/signing-disabled.yaml rename to unittests/helm/deployment/signingDisabled.yaml diff --git a/unittests/helm/deployment/signing-enabled.yaml b/unittests/helm/deployment/signingEnabled.yaml similarity index 100% rename from unittests/helm/deployment/signing-enabled.yaml rename to unittests/helm/deployment/signingEnabled.yaml diff --git a/unittests/helm/deployment/ssh-configuration.yaml b/unittests/helm/deployment/sshConfiguration.yaml similarity index 100% rename from unittests/helm/deployment/ssh-configuration.yaml rename to unittests/helm/deployment/sshConfiguration.yaml diff --git a/unittests/helm/deployment/deprecations.yaml b/unittests/helm/deprecation/deployment.yaml similarity index 100% rename from unittests/helm/deployment/deprecations.yaml rename to unittests/helm/deprecation/deployment.yaml diff --git a/unittests/helm/gpg-secret/signing-disabled.yaml b/unittests/helm/gpg-secret/signingDisabled.yaml similarity index 100% rename from unittests/helm/gpg-secret/signing-disabled.yaml rename to unittests/helm/gpg-secret/signingDisabled.yaml diff --git a/unittests/helm/gpg-secret/signing-enabled.yaml b/unittests/helm/gpg-secret/signingEnabled.yaml similarity index 100% rename from unittests/helm/gpg-secret/signing-enabled.yaml rename to unittests/helm/gpg-secret/signingEnabled.yaml diff --git a/unittests/helm/ingress/ingress.yaml b/unittests/helm/ingress/basics.yaml similarity index 100% rename from unittests/helm/ingress/ingress.yaml rename to unittests/helm/ingress/basics.yaml diff --git a/unittests/helm/init/basic.yaml b/unittests/helm/init/basics.yaml similarity index 100% rename from unittests/helm/init/basic.yaml rename to unittests/helm/init/basics.yaml diff --git a/unittests/helm/init/init_directory_structure.sh.yaml b/unittests/helm/init/directoryStructureScript.yaml similarity index 100% rename from unittests/helm/init/init_directory_structure.sh.yaml rename to unittests/helm/init/directoryStructureScript.yaml diff --git a/unittests/helm/init/init_directory_structure.sh-rootless.yaml b/unittests/helm/init/directoryStructureScriptRootless.yaml similarity index 100% rename from unittests/helm/init/init_directory_structure.sh-rootless.yaml rename to unittests/helm/init/directoryStructureScriptRootless.yaml diff --git a/unittests/helm/metric-secret/metrics-secret-servicemonitor-disabled.yaml b/unittests/helm/metric-secret/monitoringDisabled.yaml similarity index 100% rename from unittests/helm/metric-secret/metrics-secret-servicemonitor-disabled.yaml rename to unittests/helm/metric-secret/monitoringDisabled.yaml diff --git a/unittests/helm/metric-secret/metrics-secret-servicemonitor-enabled.yaml b/unittests/helm/metric-secret/monitoringEnabled.yaml similarity index 100% rename from unittests/helm/metric-secret/metrics-secret-servicemonitor-enabled.yaml rename to unittests/helm/metric-secret/monitoringEnabled.yaml diff --git a/unittests/helm/persistentVolumeClaim/persistentVolumeClaim.yaml b/unittests/helm/persistentVolumeClaim/basics.yaml similarity index 100% rename from unittests/helm/persistentVolumeClaim/persistentVolumeClaim.yaml rename to unittests/helm/persistentVolumeClaim/basics.yaml diff --git a/unittests/helm/deployment/storage-class-configuration.yaml b/unittests/helm/persistentVolumeClaim/storageClass.yaml similarity index 89% rename from unittests/helm/deployment/storage-class-configuration.yaml rename to unittests/helm/persistentVolumeClaim/storageClass.yaml index 929ce9a..8dd9ec8 100644 --- a/unittests/helm/deployment/storage-class-configuration.yaml +++ b/unittests/helm/persistentVolumeClaim/storageClass.yaml @@ -3,7 +3,7 @@ chart: release: name: gitea-unittests namespace: testing -suite: Test deployment storage class configuration +suite: Test persistentVolumeClaim storage class templates: - templates/persistentVolumeClaim.yaml tests: diff --git a/unittests/helm/route/basic.yaml b/unittests/helm/route/basics.yaml similarity index 100% rename from unittests/helm/route/basic.yaml rename to unittests/helm/route/basics.yaml diff --git a/unittests/helm/deployment/svc-configuration.yaml b/unittests/helm/service/configuration.yaml similarity index 100% rename from unittests/helm/deployment/svc-configuration.yaml rename to unittests/helm/service/configuration.yaml diff --git a/unittests/helm/serviceAccount/serviceAccount.yaml b/unittests/helm/serviceAccount/basics.yaml similarity index 100% rename from unittests/helm/serviceAccount/serviceAccount.yaml rename to unittests/helm/serviceAccount/basics.yaml diff --git a/unittests/helm/servicemonitor/basic.yaml b/unittests/helm/servicemonitor/basics.yaml similarity index 100% rename from unittests/helm/servicemonitor/basic.yaml rename to unittests/helm/servicemonitor/basics.yaml diff --git a/unittests/helm/servicemonitor/servicemonitor-disabled.yaml b/unittests/helm/servicemonitor/monitoringDisabled.yaml similarity index 100% rename from unittests/helm/servicemonitor/servicemonitor-disabled.yaml rename to unittests/helm/servicemonitor/monitoringDisabled.yaml diff --git a/unittests/helm/servicemonitor/servicemonitor-enabled.yaml b/unittests/helm/servicemonitor/monitoringEnabled.yaml similarity index 100% rename from unittests/helm/servicemonitor/servicemonitor-enabled.yaml rename to unittests/helm/servicemonitor/monitoringEnabled.yaml