Files
Jonathan Miller c572fcfe04
PR RC Release / Build RC Release (pull_request) Failing after 0s
Branch Policy Check / Verify merge target (pull_request) Failing after 0s
chore(core): rename Go module from code.gitea.io/gitea to MokoGitea namespace
Rename the Go module path from code.gitea.io/gitea to
git.mokoconsulting.tech/MokoConsulting/MokoGitea across the entire
codebase.

Scope:
- go.mod module declaration
- 2,235 Go source files (import paths)
- Dockerfile WORKDIR and COPY paths
- Swagger API templates
- golangci.yml linter config

External dependencies (code.gitea.io/gitea-vet, code.gitea.io/sdk/gitea,
gitea.com/gitea/act, etc.) are intentionally NOT renamed — they are
separate upstream modules.

Closes #132

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-25 00:22:38 -05:00

136 lines
3.2 KiB
Go

// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package migrations
import (
"os"
"path/filepath"
"runtime"
"testing"
"time"
"git.mokoconsulting.tech/MokoConsulting/MokoGitea/models/unittest"
base "git.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/migration"
"github.com/stretchr/testify/assert"
)
func TestGogsDownloadRepo(t *testing.T) {
token := os.Getenv("GOGS_READ_TOKEN")
liveMode := token != ""
_, callerFile, _, _ := runtime.Caller(0)
fixtureDir := filepath.Join(filepath.Dir(callerFile), "_mock_data/TestGogsDownloadRepo")
mockServer := unittest.NewMockWebServer(t, "https://try.gogs.io", fixtureDir, liveMode)
ctx := t.Context()
downloader := NewGogsDownloader(ctx, mockServer.URL, "", "", token, "lunnytest", "TESTREPO")
repo, err := downloader.GetRepoInfo(ctx)
assert.NoError(t, err)
assertRepositoryEqual(t, &base.Repository{
Name: "TESTREPO",
Owner: "lunnytest",
Description: "",
CloneURL: mockServer.URL + "/lunnytest/TESTREPO.git",
OriginalURL: mockServer.URL + "/lunnytest/TESTREPO",
DefaultBranch: "master",
}, repo)
milestones, err := downloader.GetMilestones(ctx)
assert.NoError(t, err)
assertMilestonesEqual(t, []*base.Milestone{
{
Title: "1.0",
State: "open",
},
}, milestones)
labels, err := downloader.GetLabels(ctx)
assert.NoError(t, err)
assertLabelsEqual(t, []*base.Label{
{
Name: "bug",
Color: "ee0701",
},
{
Name: "duplicate",
Color: "cccccc",
},
{
Name: "enhancement",
Color: "84b6eb",
},
{
Name: "help wanted",
Color: "128a0c",
},
{
Name: "invalid",
Color: "e6e6e6",
},
{
Name: "question",
Color: "cc317c",
},
{
Name: "wontfix",
Color: "ffffff",
},
}, labels)
// downloader.GetIssues()
issues, isEnd, err := downloader.GetIssues(ctx, 1, 8)
assert.NoError(t, err)
assert.False(t, isEnd)
assertIssuesEqual(t, []*base.Issue{
{
Number: 1,
PosterID: 5331,
PosterName: "lunny",
PosterEmail: "xiaolunwen@gmail.com",
Title: "test",
Content: "test",
Milestone: "",
State: "open",
Created: time.Date(2019, 6, 11, 8, 16, 44, 0, time.UTC),
Updated: time.Date(2019, 10, 26, 11, 7, 2, 0, time.UTC),
Labels: []*base.Label{
{
Name: "bug",
Color: "ee0701",
},
},
},
}, issues)
// downloader.GetComments()
comments, _, err := downloader.GetComments(ctx, &base.Issue{Number: 1, ForeignIndex: 1})
assert.NoError(t, err)
assertCommentsEqual(t, []*base.Comment{
{
IssueIndex: 1,
PosterID: 5331,
PosterName: "lunny",
PosterEmail: "xiaolunwen@gmail.com",
Created: time.Date(2019, 6, 11, 8, 19, 50, 0, time.UTC),
Updated: time.Date(2019, 6, 11, 8, 19, 50, 0, time.UTC),
Content: "1111",
},
{
IssueIndex: 1,
PosterID: 15822,
PosterName: "clacplouf",
PosterEmail: "test1234@dbn.re",
Created: time.Date(2019, 10, 26, 11, 7, 2, 0, time.UTC),
Updated: time.Date(2019, 10, 26, 11, 7, 2, 0, time.UTC),
Content: "88888888",
},
}, comments)
// downloader.GetPullRequests()
_, _, err = downloader.GetPullRequests(ctx, 1, 3)
assert.Error(t, err)
}