From 2837f13897bc05c419e18d2df4bff9758eab800d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Duffeck?= Date: Fri, 4 Feb 2022 09:37:25 +0100 Subject: [PATCH] Also cover readLocksIntoOpaque in the tests --- .../utils/decomposedfs/node/node_test.go | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pkg/storage/utils/decomposedfs/node/node_test.go b/pkg/storage/utils/decomposedfs/node/node_test.go index 210269cf287..9070912548c 100644 --- a/pkg/storage/utils/decomposedfs/node/node_test.go +++ b/pkg/storage/utils/decomposedfs/node/node_test.go @@ -19,6 +19,7 @@ package node_test import ( + "encoding/json" "time" userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" @@ -208,6 +209,25 @@ var _ = Describe("Node", func() { Expect(len(ri.Etag)).To(Equal(34)) Expect(ri.Etag).ToNot(Equal(before)) }) + + It("includes the lock in the Opaque", func() { + lock := &provider.Lock{ + Type: provider.LockType_LOCK_TYPE_EXCL, + User: env.Owner.Id, + LockId: "foo", + } + n.SetLock(env.Ctx, lock) + + perms := node.OwnerPermissions() + ri, err := n.AsResourceInfo(env.Ctx, &perms, []string{}, false) + Expect(err).ToNot(HaveOccurred()) + Expect(ri.Opaque.Map["lock"]).ToNot(BeNil()) + + storedLock := &provider.Lock{} + err = json.Unmarshal(ri.Opaque.Map["lock"].Value, storedLock) + Expect(err).ToNot(HaveOccurred()) + Expect(storedLock).To(Equal(lock)) + }) }) }) })