Skip to content

Commit

Permalink
Added testNextPutWithMessageId test case
Browse files Browse the repository at this point in the history
  • Loading branch information
mumez committed Sep 5, 2024
1 parent f837989 commit fc843ee
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 26 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
tests
testNextPutWithMessageId
| strm one two three four five invalidId conts |
strm := self newStreamNamed: 'testNextPutWithMessageId'.
strm beEmptyAndReset.
self assert: strm length equals: 0.
one := 'one' -> '1'.
two := 'two' -> '2'.
three := 'three' -> '3'.
four := 'four' -> '4'.
five := 'five' -> '5'.
invalidId := RsStreamMessageId epoch.
self assert: (strm nextPut: one at: invalidId) equals: nil.
self assert: strm length equals: 0.

strm nextPut: one at: '0-1'.
strm nextPut: two at: (RsStreamMessageId mainId: 0 subId: 2).
conts := strm contents.
self assert: strm length equals: 2.
self assert: conts first content equals: one.
self assert: conts second content equals: two.

strm nextPut: three at: (RsStreamMessageId mainIdOnly: 1).
strm nextPut: four at: (RsStreamMessageId mainIdSubIncremented: 1).
self assert: (strm nextPut: five at: (RsStreamMessageId mainIdOnly: 1)) equals: nil.
conts := strm contents.
self assert: strm length equals: 4.
self assert: conts first content equals: one.
self assert: conts last content equals: four.
self assert: (conts collect: [ :each | each id ]) asArray equals: #('0-1' '0-2' '1-0' '1-1').
self assert: strm info lastGeneratedId equals: '1-1'.

strm trimLowerThan: (RsStreamMessageId mainId: 1 subId: 0).
conts := strm contents.
self assert: strm length equals: 2.
self assert: conts first content equals: three.
self assert: conts last content equals: four.

strm trimTo: 0.
self assert: strm length equals: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
deleting
beEmpty
self trimTo: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
deleting
beEmptyAndReset
self beEmpty.
self setLastMessageId: RsStreamMessageId epoch
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
trimming
trimLowerThan: messageId
^ self endpoint xTrim: self name minId: messageId
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
initialization
initFromOrderedCollection: rawValues
rawValues ifNil: [ ^ self ].
rawValues pairsDo: [ :key :value | self initVariableAt: key value: value ]
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ initVariableAt: key value: value
^ self maxDeletedEntryId: value ].
key = 'entries-added' ifTrue: [ ^ self entriesAdded: value ].
key = 'groups' ifTrue: [ ^ self initGroups: value].
key = 'first-entry' ifTrue: [ ^ self firstEntry: (RsStreamEntry fromOrderedCollection: value) ].
key = 'last-entry' ifTrue: [ ^ self lastEntry: (RsStreamEntry fromOrderedCollection: value) ].
(key = 'first-entry' and: [value notNil]) ifTrue: [ ^ self firstEntry: (RsStreamEntry fromOrderedCollection: value) ].
(key = 'last-entry' and: [value notNil]) ifTrue: [ ^ self lastEntry: (RsStreamEntry fromOrderedCollection: value) ].
key = 'recorded-first-entry-id' ifTrue: [ ^ self recordedFirstEntryId: value ].
key = 'entries' ifTrue: [ ^ self initEntries: value ].
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
minId: id
self beMinId.
self threshold: id.
self threshold: id asString.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
minIdAtLeast: id
self beMinId.
self atLeast: id
self atLeast: id asString

0 comments on commit fc843ee

Please sign in to comment.