From 98cf69a025fd1e127ca07cb5d5d92efac6c17dde Mon Sep 17 00:00:00 2001 From: "Richard T. Carback III" <rick.carback@gmail.com> Date: Sat, 24 Sep 2022 22:08:54 +0000 Subject: [PATCH] add a test to make sure uuids are working --- indexedDb/implementation_test.go | 35 ++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/indexedDb/implementation_test.go b/indexedDb/implementation_test.go index 0a954962..d8c7e255 100644 --- a/indexedDb/implementation_test.go +++ b/indexedDb/implementation_test.go @@ -122,3 +122,38 @@ func TestWasmModel_JoinChannel_LeaveChannel(t *testing.T) { t.Fatalf("Expected 1 channels to exist") } } + +// Test wasmModel.UpdateSentStatus happy path and ensure fields don't change. +func TestWasmModel_UUIDTest(t *testing.T) { + testString := "test" + testMsgId := channel.MakeMessageID([]byte(testString)) + eventModel, err := newWasmModel(testString) + if err != nil { + t.Fatalf("%+v", err) + } + + cid := channel.Identity{} + + uuids := make([]uint64, 10) + + for i := 0; i < 10; i++ { + // Store a test message + testMsg := buildMessage([]byte(testString), testMsgId.Bytes(), + nil, testString, testString, cid, time.Now(), + time.Second, channels.Sent) + uuid, err := eventModel.receiveHelper(testMsg) + if err != nil { + t.Fatalf("%+v", err) + } + uuids[i] = uuid + } + + for i := 0; i < 10; i++ { + for j := i + 1; j < 10; j++ { + if uuids[i] == uuids[j] { + t.Fatalf("uuid failed: %d[%d] == %d[%d]", + uuids[i], i, uuids[j], j) + } + } + } +} -- GitLab