From 36610101a9e6a02625ed2b8fb1dd7829b6e020dc Mon Sep 17 00:00:00 2001 From: Ildar Date: Tue, 26 Jul 2022 23:56:51 +0300 Subject: [PATCH 1/2] add license badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0a8fefd..ffeb8f3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Mongol +[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Go Reference](https://pkg.go.dev/badge/github.com/wajox/mongol.svg)](https://pkg.go.dev/github.com/wajox/mongol) [![codecov](https://codecov.io/gh/wajox/mongol/branch/master/graph/badge.svg?token=MFEF13319U)](https://codecov.io/gh/wajox/mongol) ![Go workflow](https://github.com/wajox/mongol/actions/workflows/go.yml/badge.svg) From a638874ed919bee40664d7ae5e5a8536a5185ab1 Mon Sep 17 00:00:00 2001 From: Ildar Date: Wed, 27 Jul 2022 00:00:56 +0300 Subject: [PATCH 2/2] 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{}