...
1 package kustomization
2
3 import (
4 "testing"
5
6 "github.com/stretchr/testify/assert"
7 v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
8
9 clusterApi "edge-infra.dev/pkg/edge/apis/cluster/v1alpha1"
10 "edge-infra.dev/pkg/edge/constants/api/cluster"
11 "edge-infra.dev/pkg/edge/constants/api/fleet"
12 )
13
14 func TestForemanKustomization(t *testing.T) {
15 foremanCluster := &clusterApi.Cluster{
16 ObjectMeta: v1.ObjectMeta{
17 Name: "foreman0",
18 Namespace: "edge-flux",
19 },
20 Spec: clusterApi.ClusterSpec{
21 Name: "foreman0",
22 Fleet: fleet.TopLevel,
23 Type: cluster.GKE,
24 Location: "us-central-c",
25 ProjectID: "ret-edge-dev0-foreman",
26 },
27 }
28 foremanKustomization := New().
29 SetCluster(foremanCluster).
30 UseDefaultForemanRules().
31 CreateClusterKustomizations()
32 assert.Equal(t, len(foremanKustomization), 6)
33 }
34
35 func TestStoreKustomization(t *testing.T) {
36 storeCluster := &clusterApi.Cluster{
37 ObjectMeta: v1.ObjectMeta{
38 Name: "8c4e4f90-e26c-46cf-9ad2-411305b33cb0",
39 Namespace: "edge-flux",
40 },
41 Spec: clusterApi.ClusterSpec{
42 Name: "test-store",
43 Fleet: fleet.Store,
44 Type: cluster.GKE,
45 Location: "us-central-c",
46 ProjectID: "ret-edge-fdghufdbghhs",
47 },
48 }
49 storeKustomization := New().
50 SetCluster(storeCluster).
51 UseDefaultStoreRules().
52 CreateClusterKustomizations()
53 assert.Equal(t, len(storeKustomization), 10)
54 }
55
56 func TestWarehouseKustomization(t *testing.T) {
57 storeCluster := &clusterApi.Cluster{
58 ObjectMeta: v1.ObjectMeta{
59 Name: "8c4e4f90-e26c-46cf-9ad2-411305b33cb0",
60 Namespace: "edge-flux",
61 },
62 Spec: clusterApi.ClusterSpec{
63 Name: "test-store",
64 Fleet: fleet.Store,
65 Type: cluster.GKE,
66 Location: "us-central-c",
67 ProjectID: "ret-edge-fdghufdbghhs",
68 },
69 }
70 storeKustomization := New().
71 SetCluster(storeCluster).
72 UseWarehouseRules().
73 CreateClusterKustomizations()
74 assert.Equal(t, len(storeKustomization), 2)
75 }
76
View as plain text