@@ -67,17 +67,6 @@ var _ = Describe("Repository", func() {
6767 "TraceID" : "name4" ,
6868 }
6969
70- err := repository .UpdateWithContext (context .Background (), djoemo .Set , key , updates )
71- Expect (err ).To (Equal (djoemo .ErrInvalidHashKeyValue ))
72- })
73- It ("should fail with hash key value is empty string" , func () {
74- key := djoemo .Key ().WithTableName (UserTableName ).WithHashKeyName ("UUID" ).WithHashKey ("" )
75- metricsMock .EXPECT ().Record (gomock .Any (), djoemo .OpUpdate , key , gomock .Any (), false )
76- updates := map [string ]interface {}{
77- "UserName" : "name2" ,
78- "TraceID" : "name4" ,
79- }
80-
8170 err := repository .UpdateWithContext (context .Background (), djoemo .Set , key , updates )
8271 Expect (err ).To (Equal (djoemo .ErrInvalidHashKeyValue ))
8372 })
@@ -109,54 +98,6 @@ var _ = Describe("Repository", func() {
10998 Expect (err ).To (BeNil ())
11099 })
111100
112- It ("should skip empty string values in Set update" , func () {
113- key := djoemo .Key ().WithTableName (UserTableName ).
114- WithHashKeyName ("UUID" ).
115- WithHashKey ("uuid" )
116-
117- dMock .Should ().Update (
118- dMock .WithTable (key .TableName ()),
119- dMock .WithMatch (
120- mock .InputExpect ().
121- FieldEq ("UserName" , "name2" ),
122- ),
123- ).Exec ()
124-
125- metricsMock .EXPECT ().Record (gomock .Any (), djoemo .OpUpdate , key , gomock .Any (), true )
126-
127- updates := map [string ]interface {}{
128- "UserName" : "name2" ,
129- "DeviceID" : "" ,
130- }
131-
132- err := repository .UpdateWithContext (context .Background (), djoemo .Set , key , updates )
133- Expect (err ).To (BeNil ())
134- })
135-
136- It ("should skip empty string values in SetIfNotExists update" , func () {
137- key := djoemo .Key ().WithTableName (UserTableName ).
138- WithHashKeyName ("UUID" ).
139- WithHashKey ("uuid" )
140-
141- dMock .Should ().Update (
142- dMock .WithTable (key .TableName ()),
143- dMock .WithMatch (
144- mock .InputExpect ().
145- FieldEq ("SDKHash" , "hash123" ),
146- ),
147- ).Exec ()
148-
149- metricsMock .EXPECT ().Record (gomock .Any (), djoemo .OpUpdate , key , gomock .Any (), true )
150-
151- updates := map [string ]interface {}{
152- "SDKHash" : "hash123" ,
153- "DeviceName" : "" ,
154- }
155-
156- err := repository .UpdateWithContext (context .Background (), djoemo .SetIfNotExists , key , updates )
157- Expect (err ).To (BeNil ())
158- })
159-
160101 It ("should Update item with SetSet" , func () {
161102 key := djoemo .Key ().WithTableName (UserTableName ).
162103 WithHashKeyName ("UUID" ).
@@ -274,82 +215,6 @@ var _ = Describe("Repository", func() {
274215 })
275216 })
276217
277- Describe ("UpdateWithUpdateExpressions" , func () {
278- It ("should update item with mixed Set and SetIfNotExists expressions" , func () {
279- key := djoemo .Key ().WithTableName (UserTableName ).
280- WithHashKeyName ("UUID" ).
281- WithHashKey ("uuid" )
282-
283- dMock .Should ().Update (
284- dMock .WithTable (key .TableName ()),
285- dMock .WithMatch (
286- mock .InputExpect ().
287- FieldEq ("UserName" , "name2" ).FieldEq ("SDKHash" , "hash123" ),
288- ),
289- ).Exec ()
290-
291- metricsMock .EXPECT ().Record (gomock .Any (), djoemo .OpUpdate , key , gomock .Any (), true )
292-
293- updateExpressions := djoemo.UpdateExpressions {
294- djoemo .Set : {
295- "UserName" : "name2" ,
296- },
297- djoemo .SetIfNotExists : {
298- "SDKHash" : "hash123" ,
299- },
300- }
301-
302- err := repository .UpdateWithUpdateExpressions (context .Background (), key , updateExpressions )
303- Expect (err ).To (BeNil ())
304- })
305-
306- It ("should fail with hash key value is empty string" , func () {
307- key := djoemo .Key ().WithTableName (UserTableName ).WithHashKeyName ("UUID" ).WithHashKey ("" )
308- metricsMock .EXPECT ().Record (gomock .Any (), djoemo .OpUpdate , key , gomock .Any (), false )
309-
310- updateExpressions := djoemo.UpdateExpressions {
311- djoemo .Set : {
312- "UserName" : "name2" ,
313- },
314- }
315-
316- err := repository .UpdateWithUpdateExpressions (context .Background (), key , updateExpressions )
317- Expect (err ).To (Equal (djoemo .ErrInvalidHashKeyValue ))
318- })
319-
320- It ("should skip empty string values in Set and SetIfNotExists expressions" , func () {
321- key := djoemo .Key ().WithTableName (UserTableName ).
322- WithHashKeyName ("UUID" ).
323- WithHashKey ("uuid" )
324-
325- dMock .Should ().Update (
326- dMock .WithTable (key .TableName ()),
327- dMock .WithMatch (
328- mock .InputExpect ().
329- FieldEq ("UserName" , "name2" ).FieldEq ("SDKHash" , "hash123" ),
330- ),
331- ).Exec ()
332-
333- metricsMock .EXPECT ().Record (gomock .Any (), djoemo .OpUpdate , key , gomock .Any (), true )
334-
335- updateExpressions := djoemo.UpdateExpressions {
336- djoemo .Set : {
337- "UserName" : "name2" ,
338- "DeviceID" : "" ,
339- "ProductName" : "" ,
340- },
341- djoemo .SetIfNotExists : {
342- "SDKHash" : "hash123" ,
343- "DeviceName" : "" ,
344- "DeviceType" : "" ,
345- },
346- }
347-
348- err := repository .UpdateWithUpdateExpressions (context .Background (), key , updateExpressions )
349- Expect (err ).To (BeNil ())
350- })
351- })
352-
353218 Describe ("UpdateItem with condition" , func () {
354219 It ("should save an item if the condition is met" , func () {
355220 key := djoemo .Key ().WithTableName (UserTableName ).
0 commit comments