package gitea_test import ( "context" "net/http" "net/http/httptest" "testing" "gitea.d-ma.be/mathias/gitea-mcp/internal/gitea" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestListRepos(t *testing.T) { srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { assert.Equal(t, "/api/v1/users/mathias/repos", r.URL.Path) assert.Equal(t, "1", r.URL.Query().Get("page")) assert.Equal(t, "10", r.URL.Query().Get("limit")) w.Header().Set("Content-Type", "application/json") _, _ = w.Write([]byte(`[{"name":"infra","full_name":"mathias/infra","default_branch":"main","description":"d","private":true}]`)) })) defer srv.Close() c := gitea.NewClient(srv.URL, "tok") repos, err := c.ListRepos(context.Background(), "mathias", 1, 10) require.NoError(t, err) require.Len(t, repos, 1) assert.Equal(t, "mathias/infra", repos[0].FullName) assert.Equal(t, "main", repos[0].DefaultBranch) }