|
5 | 5 | "fmt" |
6 | 6 | . "github.com/codeready-toolchain/member-operator/test" |
7 | 7 | "github.com/codeready-toolchain/toolchain-common/pkg/test" |
8 | | - "github.com/stretchr/testify/assert" |
9 | 8 | "github.com/stretchr/testify/require" |
10 | 9 | corev1 "k8s.io/api/core/v1" |
11 | 10 | rbac "k8s.io/api/rbac/v1" |
@@ -75,84 +74,6 @@ func TestDeleteConsoleSettingObjects(t *testing.T) { |
75 | 74 | AssertObjectNotFound(t, cl, UserSettingNS, "user-settings-johnsmith-rolebinding", &rbac.RoleBinding{}) |
76 | 75 | }) |
77 | 76 |
|
78 | | - t.Run("Object found by label and deletes successfully", func(t *testing.T) { |
79 | | - // given |
80 | | - cm := &corev1.ConfigMap{ |
81 | | - TypeMeta: metav1.TypeMeta{Kind: "ConfigMap"}, |
82 | | - ObjectMeta: metav1.ObjectMeta{ |
83 | | - Name: "user-settings-name-no-match", |
84 | | - Namespace: UserSettingNS, |
85 | | - Labels: map[string]string{ |
86 | | - ConsoleUserSettingsIdentifier: "true", |
87 | | - ConsoleUserSettingsUID: "johnsmith", |
88 | | - }, |
89 | | - }, |
90 | | - } |
91 | | - // create a noise objects where the labels don't match |
92 | | - noiseObject := &corev1.ConfigMap{ |
93 | | - TypeMeta: metav1.TypeMeta{ |
94 | | - Kind: "ConfigMap", |
95 | | - APIVersion: "v1", |
96 | | - }, |
97 | | - ObjectMeta: metav1.ObjectMeta{ |
98 | | - Name: "user-settings-name-no-match-noise", |
99 | | - Namespace: UserSettingNS, |
100 | | - Labels: map[string]string{ |
101 | | - ConsoleUserSettingsIdentifier: "true", |
102 | | - }, |
103 | | - }, |
104 | | - } |
105 | | - cl := test.NewFakeClient(t, cm, noiseObject) |
106 | | - |
107 | | - // when |
108 | | - err := deleteResource(context.TODO(), cl, "johnsmith", &corev1.ConfigMap{}) |
109 | | - |
110 | | - // then |
111 | | - require.NoError(t, err) |
112 | | - // check that the configmap doesn't exist anymore |
113 | | - AssertObjectNotFound(t, cl, UserSettingNS, "johnsmith", &corev1.ConfigMap{}) |
114 | | - // check that the noise object still exists |
115 | | - retrievedNoise := &corev1.ConfigMap{} |
116 | | - AssertObject(t, cl, UserSettingNS, "user-settings-name-no-match-noise", retrievedNoise, func() { |
117 | | - assert.Equal(t, noiseObject, retrievedNoise) |
118 | | - }) |
119 | | - }) |
120 | | - t.Run("multiple objects found by label and deletes successfully", func(t *testing.T) { |
121 | | - // given |
122 | | - cm1 := &corev1.ConfigMap{ |
123 | | - TypeMeta: metav1.TypeMeta{Kind: "ConfigMap"}, |
124 | | - ObjectMeta: metav1.ObjectMeta{ |
125 | | - Name: "user-settings-name-no-match", |
126 | | - Namespace: UserSettingNS, |
127 | | - Labels: map[string]string{ |
128 | | - ConsoleUserSettingsIdentifier: "true", |
129 | | - ConsoleUserSettingsUID: "johnsmith", |
130 | | - }, |
131 | | - }, |
132 | | - } |
133 | | - cm2 := &corev1.ConfigMap{ |
134 | | - TypeMeta: metav1.TypeMeta{Kind: "ConfigMap"}, |
135 | | - ObjectMeta: metav1.ObjectMeta{ |
136 | | - Name: "user-settings-name-no-match-second", |
137 | | - Namespace: UserSettingNS, |
138 | | - Labels: map[string]string{ |
139 | | - ConsoleUserSettingsIdentifier: "true", |
140 | | - ConsoleUserSettingsUID: "johnsmith", |
141 | | - }, |
142 | | - }, |
143 | | - } |
144 | | - cl := test.NewFakeClient(t, cm1, cm2) |
145 | | - |
146 | | - // when |
147 | | - err := deleteResource(context.TODO(), cl, "johnsmith", &corev1.ConfigMap{}) |
148 | | - |
149 | | - // then |
150 | | - require.NoError(t, err) |
151 | | - // check that the configmaps don't exist anymore |
152 | | - AssertObjectNotFound(t, cl, UserSettingNS, "user-settings-name-no-match", &corev1.ConfigMap{}) |
153 | | - AssertObjectNotFound(t, cl, UserSettingNS, "user-settings-name-no-match-second", &corev1.ConfigMap{}) |
154 | | - }) |
155 | | - |
156 | 77 | t.Run("Error is returned when error in deleting configmap", func(t *testing.T) { |
157 | 78 | // given |
158 | 79 | cl := test.NewFakeClient(t) |
|
0 commit comments