From a638874ed919bee40664d7ae5e5a8536a5185ab1 Mon Sep 17 00:00:00 2001 From: Ildar Date: Wed, 27 Jul 2022 00:00:56 +0300 Subject: [PATCH] add test for ReplaceOneByID() --- base_collection_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/base_collection_test.go b/base_collection_test.go index 9040a86..c4e3066 100644 --- a/base_collection_test.go +++ b/base_collection_test.go @@ -308,6 +308,23 @@ var _ = Describe("BaseCollection", func() { }) }) + Context("with wrong record ID", func() { + It("should not update the model", func() { + + curTime := time.Now().UTC().Add(time.Hour * 1) + + timecop.Freeze(curTime) + defer timecop.Return() + + newTitle := "New title " + uuid.New().String() + m.Title = newTitle + + _, updateErr := storage.ReplaceOneByID(context.TODO(), "123", m) + + Expect(updateErr).To(Equal(ErrInvalidObjectID)) + }) + }) + It("should update the model", func() { emptyModel := &ExampleModel{}