Skip to content

Commit 5b44e1c

Browse files
committed
Test suite for message storage ensures ordered map iteration
1 parent c7392e8 commit 5b44e1c

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

internal/testsuite/store_suite.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package testsuite
1717

1818
import (
19+
"sort"
1920
"time"
2021

2122
"github.com/quickfixgo/quickfix"
@@ -106,8 +107,13 @@ func (s *StoreTestSuite) TestMessageStoreSaveMessageGetMessage() {
106107
2: "they were forced to eat Robin's minstrels",
107108
3: "and there was much rejoicing",
108109
}
109-
for seqNum, msg := range expectedMsgsBySeqNum {
110-
s.Require().Nil(s.MsgStore.SaveMessage(seqNum, []byte(msg)))
110+
var seqNums []int
111+
for seqNum := range expectedMsgsBySeqNum {
112+
seqNums = append(seqNums, seqNum)
113+
}
114+
sort.Ints(seqNums)
115+
for _, seqNum := range seqNums {
116+
s.Require().Nil(s.MsgStore.SaveMessage(seqNum, []byte(expectedMsgsBySeqNum[seqNum])))
111117
}
112118

113119
// When the messages are retrieved from the MessageStore
@@ -141,8 +147,13 @@ func (s *StoreTestSuite) TestMessageStoreSaveMessageAndIncrementGetMessage() {
141147
2: "they were forced to eat Robin's minstrels",
142148
3: "and there was much rejoicing",
143149
}
144-
for seqNum, msg := range expectedMsgsBySeqNum {
145-
s.Require().Nil(s.MsgStore.SaveMessageAndIncrNextSenderMsgSeqNum(seqNum, []byte(msg)))
150+
var seqNums []int
151+
for seqNum := range expectedMsgsBySeqNum {
152+
seqNums = append(seqNums, seqNum)
153+
}
154+
sort.Ints(seqNums)
155+
for _, seqNum := range seqNums {
156+
s.Require().Nil(s.MsgStore.SaveMessageAndIncrNextSenderMsgSeqNum(seqNum, []byte(expectedMsgsBySeqNum[seqNum])))
146157
}
147158
s.Equal(423, s.MsgStore.NextSenderMsgSeqNum())
148159

0 commit comments

Comments
 (0)