Skip to content

Commit dc040b8

Browse files
committed
feat: unit tests
1 parent da764f1 commit dc040b8

File tree

3 files changed

+82
-30
lines changed

3 files changed

+82
-30
lines changed

internal/flux_deployer/deployer_test.go

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,33 @@ func TestDeployFluxController(t *testing.T) {
3131
Environment: "test",
3232
}
3333

34-
componentManager := &MockComponentManager{
35-
ComponentPath: "./testdata/01/component.yaml",
34+
d := flux_deployer.NewFluxDeployer(config, "", ocmcli.NoOcmConfig, platformCluster, logging.GetLogger())
35+
36+
// Initial deployment
37+
componentManager1 := &MockComponentManager{
38+
ComponentPath: "./testdata/01/component_1.yaml",
3639
TemplatesPath: "./testdata/01/fluxcd_resource",
3740
}
3841

39-
d := flux_deployer.NewFluxDeployer(config, "", ocmcli.NoOcmConfig, platformCluster, logging.GetLogger())
40-
41-
// Create a deployment
42-
err := d.DeployWithComponentManager(t.Context(), componentManager)
42+
err := d.DeployWithComponentManager(t.Context(), componentManager1)
4343
assert.NoError(t, err, "Error deploying flux controllers")
44-
4544
deployment := &v1.Deployment{}
4645
err = platformClient.Get(t.Context(), client.ObjectKey{Name: "source-controller", Namespace: namespace}, deployment)
4746
assert.NoError(t, err, "Error getting source-controller deployment")
4847
assert.Equal(t, namespace, deployment.Namespace, "Deployment namespace does not match expected namespace")
49-
assert.Equal(t, "ghcr.io/fluxcd/source-controller:v1.6.2", deployment.Spec.Template.Spec.Containers[0].Image, "Deployment image does not match expected image")
50-
51-
// Update the deployment
52-
// err = d.DeployFluxControllers(t.Context(), rootComponentVersion2, downloadDir)
53-
// assert.NoError(t, err, "Error updating flux controllers")
54-
//
55-
// err = platformClient.Get(t.Context(), client.ObjectKey{Name: "source-controller", Namespace: namespace}, deployment)
56-
// assert.NoError(t, err, "Error getting source-controller deployment")
57-
// assert.Equal(t, namespace, deployment.Namespace, "Deployment namespace does not match expected namespace")
58-
// assert.Equal(t, "test-source-controller-image:v0.0.2", deployment.Spec.Template.Spec.Containers[0].Image, "Deployment image does not match expected image")
48+
assert.Equal(t, "ghcr.io/fluxcd/source-controller:v1.0.0", deployment.Spec.Template.Spec.Containers[0].Image, "Deployment image does not match expected image")
49+
50+
// Update deployment
51+
componentManager2 := &MockComponentManager{
52+
ComponentPath: "./testdata/01/component_2.yaml",
53+
TemplatesPath: "./testdata/01/fluxcd_resource",
54+
}
55+
56+
err = d.DeployWithComponentManager(t.Context(), componentManager2)
57+
assert.NoError(t, err, "Error deploying flux controllers")
58+
deployment = &v1.Deployment{}
59+
err = platformClient.Get(t.Context(), client.ObjectKey{Name: "source-controller", Namespace: namespace}, deployment)
60+
assert.NoError(t, err, "Error getting source-controller deployment")
61+
assert.Equal(t, namespace, deployment.Namespace, "Deployment namespace does not match expected namespace")
62+
assert.Equal(t, "ghcr.io/fluxcd/source-controller:v2.0.0", deployment.Spec.Template.Spec.Containers[0].Image, "Deployment image does not match expected image")
5963
}
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
11
component:
22
name: github.com/openmcp-project/openmcp
3-
version: v0.0.1
3+
version: v1.0.0
44
provider:
55
name: openmcp-project
66

77
resources:
88
- name: fluxcd-source-controller
9-
version: v1.6.2
9+
version: v1.0.0
1010
type: ociImage
1111
access:
1212
type: ociArtifact
13-
imageReference: ghcr.io/fluxcd/source-controller:v1.6.2
13+
imageReference: ghcr.io/fluxcd/source-controller:v1.0.0
1414

1515
- name: fluxcd-kustomize-controller
16-
version: v1.6.1
16+
version: v1.0.1
1717
type: ociImage
1818
access:
1919
type: ociArtifact
20-
imageReference: ghcr.io/fluxcd/kustomize-controller:v1.6.1
20+
imageReference: ghcr.io/fluxcd/kustomize-controller:v1.0.1
2121

2222
- name: fluxcd-helm-controller
23-
version: v1.3.0
23+
version: v1.0.2
2424
type: ociImage
2525
access:
2626
type: ociArtifact
27-
imageReference: ghcr.io/fluxcd/helm-controller:v1.3.0
27+
imageReference: ghcr.io/fluxcd/helm-controller:v1.0.2
2828

2929
- name: fluxcd-notification-controller
30-
version: v1.6.0
30+
version: v1.0.3
3131
type: ociImage
3232
access:
3333
type: ociArtifact
34-
imageReference: ghcr.io/fluxcd/notification-controller:v1.6.0
34+
imageReference: ghcr.io/fluxcd/notification-controller:v1.0.3
3535

3636
- name: fluxcd-image-reflector-controller
37-
version: v0.35.2
37+
version: v1.0.4
3838
type: ociImage
3939
access:
4040
type: ociArtifact
41-
imageReference: ghcr.io/fluxcd/image-reflector-controller:v0.35.2
41+
imageReference: ghcr.io/fluxcd/image-reflector-controller:v1.0.4
4242

4343
- name: fluxcd-image-automation-controller
44-
version: v0.41.2
44+
version: v1.0.5
4545
type: ociImage
4646
access:
4747
type: ociArtifact
48-
imageReference: ghcr.io/fluxcd/image-automation-controller:v0.41.2
48+
imageReference: ghcr.io/fluxcd/image-automation-controller:v1.0.5
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
component:
2+
name: github.com/openmcp-project/openmcp
3+
version: v2.0.0
4+
provider:
5+
name: openmcp-project
6+
7+
resources:
8+
- name: fluxcd-source-controller
9+
version: v2.0.0
10+
type: ociImage
11+
access:
12+
type: ociArtifact
13+
imageReference: ghcr.io/fluxcd/source-controller:v2.0.0
14+
15+
- name: fluxcd-kustomize-controller
16+
version: v2.0.1
17+
type: ociImage
18+
access:
19+
type: ociArtifact
20+
imageReference: ghcr.io/fluxcd/kustomize-controller:v2.0.1
21+
22+
- name: fluxcd-helm-controller
23+
version: v2.0.2
24+
type: ociImage
25+
access:
26+
type: ociArtifact
27+
imageReference: ghcr.io/fluxcd/helm-controller:v2.0.2
28+
29+
- name: fluxcd-notification-controller
30+
version: v2.0.3
31+
type: ociImage
32+
access:
33+
type: ociArtifact
34+
imageReference: ghcr.io/fluxcd/notification-controller:v2.0.3
35+
36+
- name: fluxcd-image-reflector-controller
37+
version: v2.0.4
38+
type: ociImage
39+
access:
40+
type: ociArtifact
41+
imageReference: ghcr.io/fluxcd/image-reflector-controller:v2.0.4
42+
43+
- name: fluxcd-image-automation-controller
44+
version: v2.0.5
45+
type: ociImage
46+
access:
47+
type: ociArtifact
48+
imageReference: ghcr.io/fluxcd/image-automation-controller:v2.0.5

0 commit comments

Comments
 (0)