Skip to content
Snippets Groups Projects
Commit 020a97c5 authored by Jake Taylor's avatar Jake Taylor
Browse files

more uniqueness unit testing

parent ba904f8e
No related branches found
No related tags found
1 merge request!60Revert "Fail a test to be sure it works"
...@@ -292,8 +292,8 @@ func TestWasmModel_receiveHelper_UniqueIndex(t *testing.T) { ...@@ -292,8 +292,8 @@ func TestWasmModel_receiveHelper_UniqueIndex(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
// The duplicate entry won't fail, it just silently shouldn't happen // The duplicate entry won't fail, but it just silently shouldn't happen
_, err = eventModel.receiveHelper(testMsg, true) _, err = eventModel.receiveHelper(testMsg, false)
if err != nil { if err != nil {
t.Fatalf("%+v", err) t.Fatalf("%+v", err)
} }
...@@ -304,4 +304,31 @@ func TestWasmModel_receiveHelper_UniqueIndex(t *testing.T) { ...@@ -304,4 +304,31 @@ func TestWasmModel_receiveHelper_UniqueIndex(t *testing.T) {
if len(results) != 1 { if len(results) != 1 {
t.Fatalf("Expected only a single message, got %d", len(results)) t.Fatalf("Expected only a single message, got %d", len(results))
} }
// Now insert a message with a different message ID from the first
testMsgId2 := channel.MakeMessageID([]byte(testString), &id.ID{2})
testMsg = buildMessage([]byte(testString), testMsgId2.Bytes(), nil,
testString, testString, []byte{8, 6, 7, 5}, 0, netTime.Now(),
time.Second, 0, 0, channels.Sent)
primaryKey, err := eventModel.receiveHelper(testMsg, false)
if err != nil {
t.Fatal(err)
}
// Except this time, we update the second entry to have the same
// message ID as the first
testMsg.ID = primaryKey
testMsg.MessageID = testMsgId.Bytes()
_, err = eventModel.receiveHelper(testMsg, true)
if err != nil {
t.Fatal(err)
}
// The update to duplicate message ID won't fail,
// but it just silently shouldn't happen
results, err = eventModel.dump(messageStoreName)
if err != nil {
t.Fatalf("%+v", err)
}
// TODO: Convert JSON to Message, ensure Message ID fields differ
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment