package mysql

import "testing"

func TestLuckyGiftPendingClaimLimitReservesRetryableQuota(t *testing.T) {
	tests := []struct {
		name      string
		batchSize int
		want      int
	}{
		{name: "empty", batchSize: 0, want: 0},
		{name: "single slot goes to pending", batchSize: 1, want: 1},
		{name: "small batch keeps one retryable slot", batchSize: 4, want: 3},
		{name: "default batch reserves ten percent", batchSize: 100, want: 90},
		{name: "max batch reserves ten percent", batchSize: 500, want: 450},
	}

	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := luckyGiftPendingClaimLimit(tt.batchSize); got != tt.want {
				t.Fatalf("luckyGiftPendingClaimLimit(%d) = %d, want %d", tt.batchSize, got, tt.want)
			}
		})
	}
}
