package automation

import (
	"net/http/httptest"
	"testing"

	automationservice "github.com/tidbcloud/AgentTeam/internal/service/automation"
)

func TestAutomationRepositoryPaginationHasExplicitCap(t *testing.T) {
	request := httptest.NewRequest("GET", "/api/v1/automations/repositories?page=1&perPage=5000", nil)

	_, defaultPerPage := paginationWithMax(request, maxPerPage)
	if defaultPerPage != maxPerPage {
		t.Fatalf("pagination perPage = %d, want %d", defaultPerPage, maxPerPage)
	}
	_, repositoryPerPage := paginationWithMax(request, automationservice.MaxAutomationRepositorySourceCandidates)
	if repositoryPerPage != automationservice.MaxAutomationRepositorySourceCandidates {
		t.Fatalf("repository pagination perPage = %d, want %d", repositoryPerPage, automationservice.MaxAutomationRepositorySourceCandidates)
	}
}
