|
| 1 | +--- |
| 2 | +# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json |
| 3 | +suite: rhoso-apps application template |
| 4 | +templates: |
| 5 | + - application.yaml |
| 6 | +tests: |
| 7 | + # Helm merges values; we cannot replace the whole applications map from tests. |
| 8 | + # Assert on one real Application from values.yaml via documentSelector. |
| 9 | + - it: renders openstack-controlplane Application from default values |
| 10 | + values: |
| 11 | + - ../values.yaml |
| 12 | + documentSelector: |
| 13 | + path: metadata.name |
| 14 | + value: openstack-controlplane |
| 15 | + asserts: |
| 16 | + - isKind: |
| 17 | + of: Application |
| 18 | + - equal: |
| 19 | + path: apiVersion |
| 20 | + value: argoproj.io/v1alpha1 |
| 21 | + - equal: |
| 22 | + path: metadata.name |
| 23 | + value: openstack-controlplane |
| 24 | + - equal: |
| 25 | + path: metadata.namespace |
| 26 | + value: openshift-gitops |
| 27 | + - equal: |
| 28 | + path: metadata.finalizers[0] |
| 29 | + value: resources-finalizer.argocd.argoproj.io/foreground |
| 30 | + - equal: |
| 31 | + path: metadata.annotations["argocd.argoproj.io/sync-wave"] |
| 32 | + value: "10" |
| 33 | + - equal: |
| 34 | + path: spec.project |
| 35 | + value: default |
| 36 | + - equal: |
| 37 | + path: spec.source.repoURL |
| 38 | + value: https://github.com/openstack-k8s-operators/gitops |
| 39 | + - equal: |
| 40 | + path: spec.source.path |
| 41 | + value: examples/controlplane |
| 42 | + - equal: |
| 43 | + path: spec.source.targetRevision |
| 44 | + value: v0.1.0 |
| 45 | + - equal: |
| 46 | + path: spec.destination.server |
| 47 | + value: https://kubernetes.default.svc |
| 48 | + - equal: |
| 49 | + path: spec.syncPolicy.syncOptions[0] |
| 50 | + value: Prune=true |
| 51 | + |
| 52 | + - it: renders operator-dependencies with default background finalizer |
| 53 | + values: |
| 54 | + - ../values.yaml |
| 55 | + documentSelector: |
| 56 | + path: metadata.name |
| 57 | + value: operator-dependencies |
| 58 | + asserts: |
| 59 | + - equal: |
| 60 | + path: metadata.finalizers[0] |
| 61 | + value: resources-finalizer.argocd.argoproj.io/background |
| 62 | + |
| 63 | + - it: omits spec.source.kustomize when not set in values |
| 64 | + values: |
| 65 | + - ../values.yaml |
| 66 | + documentSelector: |
| 67 | + path: metadata.name |
| 68 | + value: operator-dependencies |
| 69 | + asserts: |
| 70 | + - notExists: |
| 71 | + path: spec.source.kustomize |
| 72 | + |
| 73 | + - it: renders spec.source.kustomize when applications entry sets kustomize |
| 74 | + set: |
| 75 | + applicationNamespace: openshift-gitops |
| 76 | + destinationServer: https://kubernetes.default.svc |
| 77 | + applications: |
| 78 | + kustom-test: |
| 79 | + enabled: true |
| 80 | + repoURL: https://github.com/example/repo |
| 81 | + path: examples/foo |
| 82 | + targetRevision: main |
| 83 | + syncWave: "0" |
| 84 | + syncOptions: |
| 85 | + - Prune=true |
| 86 | + kustomize: |
| 87 | + namePrefix: dev- |
| 88 | + components: |
| 89 | + - https://github.com/example/components/overlay |
| 90 | + documentSelector: |
| 91 | + path: metadata.name |
| 92 | + value: kustom-test |
| 93 | + asserts: |
| 94 | + - equal: |
| 95 | + path: spec.source.kustomize.namePrefix |
| 96 | + value: dev- |
| 97 | + - equal: |
| 98 | + path: spec.source.kustomize.components[0] |
| 99 | + value: https://github.com/example/components/overlay |
| 100 | + |
| 101 | + - it: fails values schema when repoURL is missing |
| 102 | + set: |
| 103 | + applicationNamespace: openshift-gitops |
| 104 | + destinationServer: https://kubernetes.default.svc |
| 105 | + applications: |
| 106 | + bad: |
| 107 | + enabled: true |
| 108 | + path: "." |
| 109 | + targetRevision: main |
| 110 | + syncWave: "0" |
| 111 | + syncOptions: [] |
| 112 | + asserts: |
| 113 | + - failedTemplate: |
| 114 | + errorPattern: repoURL |
| 115 | + |
| 116 | + - it: fails values schema when destinationServer is not an https URI |
| 117 | + set: |
| 118 | + applicationNamespace: openshift-gitops |
| 119 | + destinationServer: http://insecure.example |
| 120 | + applications: |
| 121 | + a: |
| 122 | + enabled: true |
| 123 | + repoURL: https://github.com/example/repo |
| 124 | + path: "." |
| 125 | + targetRevision: main |
| 126 | + syncWave: "0" |
| 127 | + syncOptions: [] |
| 128 | + asserts: |
| 129 | + - failedTemplate: |
| 130 | + errorPattern: destinationServer |
| 131 | + |
| 132 | + - it: fails values schema when finalizer is not allowed |
| 133 | + set: |
| 134 | + applicationNamespace: openshift-gitops |
| 135 | + destinationServer: https://kubernetes.default.svc |
| 136 | + applications: |
| 137 | + bad: |
| 138 | + enabled: true |
| 139 | + repoURL: https://github.com/example/repo |
| 140 | + path: "." |
| 141 | + targetRevision: main |
| 142 | + syncWave: "0" |
| 143 | + syncOptions: [] |
| 144 | + finalizers: |
| 145 | + - resources-finalizer.argocd.argoproj.io/invalid |
| 146 | + asserts: |
| 147 | + - failedTemplate: |
| 148 | + errorPattern: finalizers |
0 commit comments