* fix(HH-554): connect auto-assignment runtime policy * fix(HH-554): bound and coalesce assignment jobs * fix(HH-554): drain assignment backlog safely * fix(HH-554): hold assignment claim through retries --------- Co-authored-by: Rogee <rogee@ipao.vip>
60 lines
1.3 KiB
Go
60 lines
1.3 KiB
Go
package autoassignment
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
// --- Constructor tests ---
|
|
|
|
func TestNewRateLimiter(t *testing.T) {
|
|
rl := NewRateLimiter(nil)
|
|
assert.NotNil(t, rl)
|
|
}
|
|
|
|
func TestNewRoundRobinSelector(t *testing.T) {
|
|
rr := NewRoundRobinSelector(nil)
|
|
assert.NotNil(t, rr)
|
|
}
|
|
|
|
func TestNewLowestLoadSelector(t *testing.T) {
|
|
ll := NewLowestLoadSelector(nil)
|
|
assert.NotNil(t, ll)
|
|
}
|
|
|
|
func TestNewAssignmentService(t *testing.T) {
|
|
s := NewAssignmentService(nil, nil)
|
|
assert.NotNil(t, s)
|
|
}
|
|
|
|
// --- Model tests ---
|
|
|
|
func TestConversationQueryModel_TableName(t *testing.T) {
|
|
m := ConversationQueryModel{}
|
|
assert.NotEmpty(t, m.TableName())
|
|
}
|
|
|
|
func TestAssignmentPolicyType_Constants(t *testing.T) {
|
|
assert.Equal(t, "round_robin", string(PolicyRoundRobin))
|
|
assert.Equal(t, "lowest_load", string(PolicyLowestLoad))
|
|
}
|
|
|
|
// --- RateLimiter key test ---
|
|
|
|
func TestRateLimiter_Key(t *testing.T) {
|
|
rl := NewRateLimiter(nil)
|
|
key := rl.key(1, 2, 300)
|
|
assert.Contains(t, key, "gochat:auto_assignment_rate:")
|
|
assert.Contains(t, key, "1")
|
|
assert.Contains(t, key, "2")
|
|
}
|
|
|
|
// --- RoundRobinSelector key test ---
|
|
|
|
func TestRoundRobinSelector_Key(t *testing.T) {
|
|
rr := NewRoundRobinSelector(nil)
|
|
key := rr.key(42)
|
|
assert.Equal(t, "gochat:round_robin:42", key)
|
|
}
|