Files
helm-gitea/unittests/helm/ingress/basics.yaml
T
volker.raschekandCopilot eeacda2a25 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 <copilot@github.com>
2026-10-03 22:19:39 +02:00

156 lines
3.9 KiB
YAML

chart:
appVersion: 1.27.3
release:
name: gitea-unittests
namespace: testing
suite: Test ingress
templates:
- templates/ingress.yaml
tests:
- it: Skip ingress if ingress is disabled
set:
ingress.enabled: false
service.http.enabled: true
asserts:
- hasDocuments:
count: 0
- it: Skip ingress if HTTP Service is disabled
set:
ingress.enabled: true
service.http.enabled: false
asserts:
- hasDocuments:
count: 0
- it: Skip ingress if both ingress and HTTP Service are disabled
set:
ingress.enabled: false
service.http.enabled: false
asserts:
- hasDocuments:
count: 0
- it: Render ingress with default values
set:
ingress.enabled: true
service.http.enabled: true
asserts:
- hasDocuments:
count: 1
- containsDocument:
kind: Ingress
apiVersion: networking.k8s.io/v1
name: gitea-unittests
namespace: testing
- notExists:
path: metadata.annotations
- isSubset:
path: metadata.labels
content:
app: gitea
app.kubernetes.io/instance: gitea-unittests
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: gitea
app.kubernetes.io/version: 1.27.3
helm.sh/chart: gitea-0.0.0
version: 1.27.3
- equal:
path: spec.ingressClassName
value: nginx
- contains:
path: spec.rules
content:
host: git.example.com
http:
paths:
- backend:
service:
name: gitea-unittests-http
port:
number: 3000
path: /
pathType: Prefix
- it: Render ingress with TLS
set:
ingress.enabled: true
ingress.tls:
- hosts:
- git.example.com
secretName: tls-secret
service.http.enabled: true
asserts:
- hasDocuments:
count: 1
- contains:
path: spec.tls
content:
hosts:
- git.example.com
secretName: tls-secret
- it: Render ingress with a custom ingressClassName
set:
ingress.enabled: true
ingress.ingressClassName: traefik
service.http.enabled: true
asserts:
- hasDocuments:
count: 1
- equal:
path: spec.ingressClassName
value: traefik
- it: Render ingress with custom HTTP service spec
set:
ingress.enabled: true
service.http.enabled: true
service.http.port: 32000
asserts:
- hasDocuments:
count: 1
- containsDocument:
kind: Ingress
apiVersion: networking.k8s.io/v1
name: gitea-unittests
namespace: testing
- contains:
path: spec.rules
content:
host: git.example.com
http:
paths:
- backend:
service:
name: gitea-unittests-http
port:
number: 32000
path: /
pathType: Prefix
- it: Render ingress with custom annotations and labels
set:
ingress.enabled: true
ingress.annotations:
custom-annotation: custom-value
ingress.labels:
custom-label: custom-value
service.http.enabled: true
asserts:
- hasDocuments:
count: 1
- containsDocument:
kind: Ingress
apiVersion: networking.k8s.io/v1
name: gitea-unittests
namespace: testing
- isSubset:
path: metadata.annotations
content:
custom-annotation: custom-value
- isSubset:
path: metadata.labels
content:
custom-label: custom-value