70 lines
1.4 KiB
Go
70 lines
1.4 KiB
Go
package worker
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestWithWorkerCount_Cov2(t *testing.T) {
|
|
opt := WithWorkerCount(5)
|
|
wp := &WorkerPool{}
|
|
opt(wp)
|
|
assert.Equal(t, 5, wp.workerCount)
|
|
}
|
|
|
|
func TestWithWorkerCount_Zero_Cov2(t *testing.T) {
|
|
opt := WithWorkerCount(0)
|
|
wp := &WorkerPool{workerCount: 3}
|
|
opt(wp)
|
|
assert.Equal(t, 3, wp.workerCount)
|
|
}
|
|
|
|
func TestWithStreamPrefix_Cov2(t *testing.T) {
|
|
opt := WithStreamPrefix("test")
|
|
wp := &WorkerPool{}
|
|
opt(wp)
|
|
assert.Equal(t, "test", wp.streamPrefix)
|
|
}
|
|
|
|
func TestWithStreamPrefix_Empty_Cov2(t *testing.T) {
|
|
opt := WithStreamPrefix("")
|
|
wp := &WorkerPool{streamPrefix: "default"}
|
|
opt(wp)
|
|
assert.Equal(t, "default", wp.streamPrefix)
|
|
}
|
|
|
|
func TestWithConsumerGroup_Cov2(t *testing.T) {
|
|
opt := WithConsumerGroup("group1")
|
|
wp := &WorkerPool{}
|
|
opt(wp)
|
|
assert.Equal(t, "group1", wp.consumerGroup)
|
|
}
|
|
|
|
func TestWithConsumerGroup_Empty_Cov2(t *testing.T) {
|
|
opt := WithConsumerGroup("")
|
|
wp := &WorkerPool{consumerGroup: "default"}
|
|
opt(wp)
|
|
assert.Equal(t, "default", wp.consumerGroup)
|
|
}
|
|
|
|
func TestDefaultBackoff_Cov2(t *testing.T) {
|
|
d := defaultBackoff(0)
|
|
assert.True(t, d > 0)
|
|
|
|
d1 := defaultBackoff(1)
|
|
d2 := defaultBackoff(2)
|
|
assert.True(t, d2 >= d1)
|
|
}
|
|
|
|
func TestDefaultBackoff_Negative_Cov2(t *testing.T) {
|
|
d := defaultBackoff(-1)
|
|
assert.True(t, d > 0)
|
|
}
|
|
|
|
func TestDefaultBackoff_Large_Cov2(t *testing.T) {
|
|
d := defaultBackoff(100)
|
|
assert.True(t, d > 0)
|
|
// Should be positive
|
|
}
|