Skip to content

Commit

Permalink
Merge pull request #39 from mumez/feature/stream-objects
Browse files Browse the repository at this point in the history
Added delete API tests to RSRedisStreamTest
  • Loading branch information
mumez authored Sep 3, 2024
2 parents 766fc8d + d5d4698 commit cf91786
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ testComing
self assert: nextThree first content equals: '2' -> '2'.
self assert: nextThree second content equals: '3' -> '3'.
self assert: nextThree third content equals: '4' -> '4'.
self assert: strm length > 6.
self assert: strm length >= 5.
strm trimTo: 0.
self assert: strm length equals: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
tests
testDelete
| strm one two three msgId conts deletedCount |
strm := self newStreamNamed: 'testDelete'.
strm trimTo: 0.
self assert: strm length equals: 0.
one := 'one' -> '1'.
two := 'two' -> '2'.
three := 'three' -> '3'.
strm nextPut: one.
msgId := strm nextPut: two.
strm nextPut: three.

conts := strm contents.
self assert: conts size equals: 3.
conts := strm first: 2.
self assert: conts size equals: 2.
self assert: conts first content equals: one.
self assert: conts second content equals: two.

deletedCount := strm deleteAt: msgId.
self assert: deletedCount equals: 1.
conts := strm contents.
self assert: conts size equals: 2.
conts := strm first: 2.
self assert: conts size equals: 2.
self assert: conts first content equals: one.
self assert: conts second content equals: three.

strm trimTo: 0.
self assert: strm length equals: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
tests
testDeletes
| strm one two three msgIds conts deletedCount |
strm := self newStreamNamed: 'testDeletes'.
strm trimTo: 0.
self assert: strm length equals: 0.
one := 'one' -> '1'.
two := 'two' -> '2'.
three := 'three' -> '3'.
strm nextPut: one.
msgIds := { two. three } collect: [:each | strm nextPut: each].

conts := strm contents.
self assert: conts size equals: 3.
conts := strm first: 2.
self assert: conts size equals: 2.
self assert: conts first content equals: one.
self assert: conts second content equals: two.

deletedCount := strm deleteAtIds: msgIds.
self assert: deletedCount equals: 2.
conts := strm contents.
self assert: conts size equals: 1.
conts := strm first: 2.
self assert: conts size equals: 1.
self assert: conts first content equals: one.

strm trimTo: 0.
self assert: strm length equals: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
deleting
deleteAtIds: streamMessageIds
^ self endpoint xDel: self name ids: streamMessageIds
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
adding
nextPutAll: keyValuesOrAssociations
^ keyValuesOrAssociations do: [ :each | self nextPut: each ]
^ keyValuesOrAssociations collect: [ :each | self nextPut: each ]
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
adding
nextPutAssociations: keyValueAssocs at: streamMessageId trimUsing: optionsBlock
^ self endpoint
xAdd: self name
createNotExists: self autoCreate
trimUsing: optionsBlock
id: streamMessageId
fieldsAndValues: keyValueAssocs
^ RsStreamMessageId fromStringOrNil: (self endpoint
xAdd: self name
createNotExists: self autoCreate
trimUsing: optionsBlock
id: streamMessageId
fieldsAndValues: keyValueAssocs)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
instance creation
fromStringOrNil: aStringOrNil
aStringOrNil ifNil: [ ^nil ].
^ self fromString: aStringOrNil
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ xDel: key id: id
^ self unifiedCommand: {
'XDEL'.
key.
id }
id asString }
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
*RediStick-Stream
xDel: key ids: ids

^ self unifiedCommand: {
'XDEL'.
key.
}, ids asArray
| args |
args := {
'XDEL'.
key } asOrderedCollection.
args addAll: (ids collect: [ :each | each asString ]).
^ self unifiedCommand: args

0 comments on commit cf91786

Please sign in to comment.