new-api/service/concurrency_wait_test.go
zizi fa77659fe8 fix(concurrency): wait when channel slots are saturated
Add a channel concurrency wait plan so saturated account/channel selection can distinguish no-wait, queue-full, and wait-for-slot outcomes while preserving fallback to other available channels first.
2026-05-25 00:37:43 +08:00

27 lines
564 B
Go

package service
import (
"context"
"testing"
"github.com/stretchr/testify/require"
)
func TestTryEnterChannelConcurrencyWaitQueueRejectsWhenPlanDisabled(t *testing.T) {
canWait, release := TryEnterChannelConcurrencyWaitQueue(1, 0)
require.False(t, canWait)
require.NotNil(t, release)
release()
}
func TestWaitForChannelConcurrencySlotTimesOut(t *testing.T) {
ctx := context.Background()
acquired, release, err := WaitForChannelConcurrencySlot(ctx, 1, 1, 0)
require.False(t, acquired)
require.NotNil(t, release)
require.Error(t, err)
release()
}