Skip to content

Commit 6256818

Browse files
committed
Add tests
1 parent 5beb891 commit 6256818

File tree

4 files changed

+162
-0
lines changed

4 files changed

+162
-0
lines changed

tests/tool/__snapshots__/test_build_ks.ambr

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,156 @@
161161
name: flux-system
162162

163163

164+
'''
165+
# ---
166+
# name: test_build_ks[build-ks-cluster11-external-artifact]
167+
'''
168+
---
169+
apiVersion: kustomize.toolkit.fluxcd.io/v1
170+
kind: Kustomization
171+
metadata:
172+
labels:
173+
kustomize.toolkit.fluxcd.io/name: flux-system
174+
kustomize.toolkit.fluxcd.io/namespace: flux-system
175+
name: apps
176+
namespace: flux-system
177+
annotations:
178+
config.kubernetes.io/index: '0'
179+
internal.config.kubernetes.io/index: '0'
180+
spec:
181+
path: ./apps/overlays/
182+
sourceRef:
183+
kind: ExternalArtifact
184+
name: apps
185+
---
186+
apiVersion: source.extensions.fluxcd.io/v1beta1
187+
kind: ArtifactGenerator
188+
metadata:
189+
labels:
190+
kustomize.toolkit.fluxcd.io/name: flux-system
191+
kustomize.toolkit.fluxcd.io/namespace: flux-system
192+
name: my-app
193+
namespace: flux-system
194+
annotations:
195+
config.kubernetes.io/index: '1'
196+
internal.config.kubernetes.io/index: '1'
197+
spec:
198+
artifacts:
199+
- copy:
200+
- from: '@base/apps/**'
201+
to: '@artifact/apps/base'
202+
- from: '@overlays/apps/overlays/**'
203+
to: '@artifact/apps/overlays/'
204+
name: apps
205+
sources:
206+
- alias: base
207+
kind: GitRepository
208+
name: shared-repo
209+
- alias: overlays
210+
kind: GitRepository
211+
name: tenant-repo
212+
---
213+
apiVersion: source.toolkit.fluxcd.io/v1
214+
kind: GitRepository
215+
metadata:
216+
labels:
217+
kustomize.toolkit.fluxcd.io/name: flux-system
218+
kustomize.toolkit.fluxcd.io/namespace: flux-system
219+
name: flux-system
220+
namespace: flux-system
221+
annotations:
222+
config.kubernetes.io/index: '2'
223+
internal.config.kubernetes.io/index: '2'
224+
spec:
225+
interval: 1m0s
226+
ref:
227+
branch: main
228+
secretRef:
229+
name: flux-system
230+
url: ssh://git@github.com/allenporter/flux-local
231+
---
232+
apiVersion: kustomize.toolkit.fluxcd.io/v1
233+
kind: Kustomization
234+
metadata:
235+
labels:
236+
kustomize.toolkit.fluxcd.io/name: flux-system
237+
kustomize.toolkit.fluxcd.io/namespace: flux-system
238+
name: flux-system
239+
namespace: flux-system
240+
annotations:
241+
config.kubernetes.io/index: '3'
242+
internal.config.kubernetes.io/index: '3'
243+
spec:
244+
interval: 10m0s
245+
path: ./tests/testdata/cluster11/cluster
246+
prune: true
247+
sourceRef:
248+
kind: GitRepository
249+
name: flux-system
250+
251+
---
252+
apiVersion: source.toolkit.fluxcd.io/v1beta2
253+
kind: HelmRepository
254+
metadata:
255+
labels:
256+
kustomize.toolkit.fluxcd.io/name: apps
257+
kustomize.toolkit.fluxcd.io/namespace: flux-system
258+
name: renovate
259+
namespace: flux-system
260+
annotations:
261+
config.kubernetes.io/index: '0'
262+
internal.config.kubernetes.io/index: '0'
263+
spec:
264+
interval: 30m
265+
url: https://docs.renovatebot.com/helm-charts
266+
---
267+
apiVersion: helm.toolkit.fluxcd.io/v2beta1
268+
kind: HelmRelease
269+
metadata:
270+
labels:
271+
kustomize.toolkit.fluxcd.io/name: apps
272+
kustomize.toolkit.fluxcd.io/namespace: flux-system
273+
name: renovate
274+
namespace: default
275+
annotations:
276+
config.kubernetes.io/index: '1'
277+
internal.config.kubernetes.io/index: '1'
278+
spec:
279+
chart:
280+
spec:
281+
chart: renovate
282+
sourceRef:
283+
kind: HelmRepository
284+
name: renovate
285+
namespace: flux-system
286+
version: 37.64.3
287+
interval: 5m
288+
values:
289+
renovate:
290+
existingConfigFile: /dev/null
291+
securityContext:
292+
allowPrivilegeEscalation: false
293+
capabilities:
294+
drop:
295+
- ALL
296+
resources:
297+
limits:
298+
cpu: 1000m
299+
memory: 2G
300+
requests:
301+
cpu: 100m
302+
memory: 256Mi
303+
securityContext:
304+
fsGroup: 1000
305+
fsGroupChangePolicy: Always
306+
runAsNonRoot: true
307+
runAsUser: 1000
308+
seccompProfile:
309+
type: RuntimeDefault
310+
serviceAccount:
311+
create: true
312+
313+
164314
'''
165315
# ---
166316
# name: test_build_ks[build-ks-single-cluster6]

tests/tool/__snapshots__/test_get_ks.ambr

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
# serializer version: 1
2+
# name: test_get_ks[cluster11]
3+
'''
4+
NAME PATH
5+
apps tests/testdata/cluster11/externalartifact/apps/overlays
6+
flux-system tests/testdata/cluster11/cluster
7+
8+
'''
9+
# ---
210
# name: test_get_ks[cluster2-wide]
311
'''
412
NAME PATH HELMREPOS OCIREPOS RELEASES

tests/tool/test_build_ks.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
(["apps", "--path=tests/testdata/cluster8/"]),
1717
(["apps-stack", "--path=tests/testdata/cluster9/clusters/dev"]),
1818
(["--path=tests/testdata/cluster10", "--skip-invalid-kustomization-paths"]),
19+
(["--path=tests/testdata/cluster11", "--sources", "flux-system,apps=tests/testdata/cluster11/externalartifact"]),
1920
],
2021
ids=[
2122
"build-ks",
@@ -24,6 +25,7 @@
2425
"build-ks-single-cluster8",
2526
"build-ks-single-cluster9",
2627
"build-ks-cluster10-invalid-paths",
28+
"build-ks-cluster11-external-artifact",
2729
],
2830
)
2931
async def test_build_ks(args: list[str], snapshot: SnapshotAssertion) -> None:

tests/tool/test_get_ks.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
(["--path", "tests/testdata/cluster2", "-o", "wide"]),
3232
(["--all-namespaces", "--path", "./tests/testdata/cluster/apps/prod"]),
3333
(["--path", "tests/testdata/cluster9/clusters/dev"]),
34+
(["--path", "tests/testdata/cluster11", "--sources", "flux-system,apps=tests/testdata/cluster11/externalartifact"]),
3435
],
3536
ids=[
3637
"cluster",
@@ -46,6 +47,7 @@
4647
"cluster2-wide",
4748
"ks_path",
4849
"cluster9",
50+
"cluster11",
4951
],
5052
)
5153
async def test_get_ks(args: list[str], snapshot: SnapshotAssertion) -> None:

0 commit comments

Comments
 (0)