-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from mumez/feature/stream-objects
Added delete API tests to RSRedisStreamTest
- Loading branch information
Showing
9 changed files
with
82 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...ory/RediStick-Stream-Objects-Tests.package/RsRedisStreamTest.class/instance/testDelete.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
29 changes: 29 additions & 0 deletions
29
...ry/RediStick-Stream-Objects-Tests.package/RsRedisStreamTest.class/instance/testDeletes.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
3 changes: 3 additions & 0 deletions
3
repository/RediStick-Stream-Objects.package/RsStream.class/instance/deleteAtIds..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
deleting | ||
deleteAtIds: streamMessageIds | ||
^ self endpoint xDel: self name ids: streamMessageIds |
2 changes: 1 addition & 1 deletion
2
repository/RediStick-Stream-Objects.package/RsStream.class/instance/nextPutAll..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ] |
12 changes: 6 additions & 6 deletions
12
...Stick-Stream-Objects.package/RsStream.class/instance/nextPutAssociations.at.trimUsing..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
4 changes: 4 additions & 0 deletions
4
...sitory/RediStick-Stream-Objects.package/RsStreamMessageId.class/class/fromStringOrNil..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
instance creation | ||
fromStringOrNil: aStringOrNil | ||
aStringOrNil ifNil: [ ^nil ]. | ||
^ self fromString: aStringOrNil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ xDel: key id: id | |
^ self unifiedCommand: { | ||
'XDEL'. | ||
key. | ||
id } | ||
id asString } |
11 changes: 6 additions & 5 deletions
11
repository/RediStick-Stream.package/RsRedisEndpoint.extension/instance/xDel.ids..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |