Skip to content

Commit

Permalink
Make linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-sili committed Jan 2, 2025
1 parent 752cc29 commit 05cec89
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions exporter/internal/queue/blocking_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@ package queue
import (
"context"
"errors"
"sync"
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestBlockingMemoryQueue(t *testing.T) {
var wg sync.WaitGroup
q := NewBlockingMemoryQueue[string](BlockingMemoryQueueSettings[string]{Sizer: &RequestSizer[string]{}, Capacity: 1})

done := false
err := errors.New("This is an error")
wg.Add(1)
go func() {
require.EqualError(t, q.Offer(context.Background(), "a"), err.Error())
done = true
assert.EqualError(t, q.Offer(context.Background(), "a"), err.Error()) // Blocks until OnProcessingFinished is called
wg.Done()
}()

require.False(t, done)
index, ctx, req, ok := q.Read(context.Background())
require.Equal(t, index, uint64(0))
require.Equal(t, ctx, context.Background())
require.Equal(t, req, "a")
require.True(t, ok)
for !ok {
index, ctx, req, ok = q.Read(context.Background())
}

require.False(t, done)
require.Equal(t, uint64(0), index)
require.Equal(t, context.Background(), ctx)
require.Equal(t, "a", req)
q.OnProcessingFinished(index, err)

time.Sleep(100 * time.Millisecond)
require.True(t, done)
wg.Wait()
}

0 comments on commit 05cec89

Please sign in to comment.