Skip to content

Commit 2918c2c

Browse files
committed
Fixup unit tests
1 parent 450639b commit 2918c2c

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

internal/controller/customresource/protection_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ func TestPatchLastConfigApplied(t *testing.T) {
216216
{
217217
title: "spec without changes is a noop",
218218
object: &akov2.AtlasProject{
219-
TypeMeta: metav1.TypeMeta{Kind: "AtlasProject", APIVersion: "atlas.mongodb.com"},
220219
ObjectMeta: metav1.ObjectMeta{Name: "test-project", Namespace: "ns", Annotations: map[string]string{}},
221220
Spec: akov2.AtlasProjectSpec{
222221
Name: "atlas-project-name",
@@ -243,7 +242,6 @@ func TestPatchLastConfigApplied(t *testing.T) {
243242
{
244243
title: "cleared spec is applied with no other changes",
245244
object: &akov2.AtlasProject{
246-
TypeMeta: metav1.TypeMeta{Kind: "AtlasProject", APIVersion: "atlas.mongodb.com"},
247245
ObjectMeta: metav1.ObjectMeta{Name: "test-project", Namespace: "ns", Annotations: map[string]string{}},
248246
Spec: akov2.AtlasProjectSpec{
249247
Name: "atlas-project-name",
@@ -309,7 +307,7 @@ func TestPatchLastConfigAppliedErrors(t *testing.T) {
309307
title: "empty struct cannot be patched",
310308
object: &akov2.AtlasProject{},
311309
spec: &struct{}{},
312-
wantErrorMsg: "failed to patch resource: \"\" is invalid: metadata.name: Required value: name is required",
310+
wantErrorMsg: "is invalid: metadata.name: Required value: name is required",
313311
},
314312
} {
315313
t.Run(tc.title, func(t *testing.T) {

pkg/controller/state/reconciler_test.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ func TestReconcile(t *testing.T) {
239239

240240
basePod := &dummyObject{
241241
Pod: corev1.Pod{
242+
TypeMeta: metav1.TypeMeta{Kind: "Pod", APIVersion: "v1"},
242243
ObjectMeta: metav1.ObjectMeta{
243244
Name: "mypod",
244245
Namespace: "default",
@@ -295,13 +296,6 @@ func TestReconcile(t *testing.T) {
295296
},
296297
wantErr: "failed to manage finalizers: simulated patch error",
297298
},
298-
{
299-
name: "check state",
300-
existingObj: basePod,
301-
handleState: func(ctx context.Context, do *dummyObject) (Result, error) {
302-
return Result{NextState: "Initial"}, nil
303-
},
304-
},
305299
}
306300

307301
for _, tc := range tests {

0 commit comments

Comments
 (0)