From af3ecc1cefc467d53d1b7d94a656b6de7c3ed0ac Mon Sep 17 00:00:00 2001 From: Ola <1386739+olahol@users.noreply.github.com> Date: Tue, 14 Mar 2023 17:33:14 +0100 Subject: [PATCH] Tests for UnSet --- .github/workflows/test.yml | 2 +- melody_test.go | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0cc0978..234ca78 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,5 +14,5 @@ jobs: with: go-version: '1.19' - run: go get -t -v ./... - - run: go test -race -coverprofile=coverage.out -covermode=atomic + - run: go test -race -coverprofile=coverage.out -covermode=atomic -timeout 5s - uses: codecov/codecov-action@v3 diff --git a/melody_test.go b/melody_test.go index 653945a..d1098cf 100644 --- a/melody_test.go +++ b/melody_test.go @@ -661,6 +661,7 @@ func TestSessionKeysConcurrent(t *testing.T) { go func() { s.Set("test", TestMsg) + v1, exists := s.Get("test") assert.True(t, exists) @@ -675,6 +676,22 @@ func TestSessionKeysConcurrent(t *testing.T) { } wg.Wait() + + for i := 0; i < 100; i++ { + wg.Add(1) + + go func() { + s.UnSet("test") + + _, exists := s.Get("test") + + assert.False(t, exists) + + wg.Done() + }() + } + + wg.Wait() } func TestMisc(t *testing.T) {