Skip to content

Commit 97ea19e

Browse files
committed
Add Test: started ...
1 parent 47e7d16 commit 97ea19e

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// Copyright 2020 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package migrations
6+
7+
import (
8+
"fmt"
9+
"net/http"
10+
"os"
11+
"sort"
12+
"testing"
13+
14+
"code.gitea.io/gitea/modules/migrations/base"
15+
16+
"github.com/stretchr/testify/assert"
17+
)
18+
19+
func TestGiteaDownloadRepo(t *testing.T) {
20+
// Skip tests if Gitea token is not found
21+
giteaToken := os.Getenv("GITEA_TOKEN")
22+
if giteaToken == "" {
23+
t.Skip("skipped test because GITEA_TOKEN was not in the environment")
24+
}
25+
26+
resp, err := http.Get("https://gitea.com/gitea")
27+
if err != nil || resp.StatusCode != 200 {
28+
t.Skipf("Can't access test repo, skipping %s", t.Name())
29+
}
30+
31+
downloader := NewGiteaDownloader("https://gitea.com", "6543/test_repo", "", "", giteaToken)
32+
if downloader == nil {
33+
t.Fatal("NewGitlabDownloader is nil")
34+
}
35+
36+
repo, err := downloader.GetRepoInfo()
37+
assert.NoError(t, err)
38+
assert.EqualValues(t, &base.Repository{
39+
Name: "test_repo",
40+
Owner: "6543",
41+
IsPrivate: false, // ToDo: set test repo private
42+
Description: "Test repository for testing migration from gitea to gitea",
43+
CloneURL: "https://gitea.com/6543/test_repo.git",
44+
OriginalURL: "https://gitea.com/6543/test_repo",
45+
}, repo)
46+
47+
topics, err := downloader.GetTopics()
48+
assert.NoError(t, err)
49+
sort.Strings(topics)
50+
assert.EqualValues(t, []string{"ci", "gitea", "migration", "test"}, topics)
51+
52+
labels, err := downloader.GetLabels()
53+
assert.NoError(t, err)
54+
assert.Len(t, labels, 6)
55+
for _, l := range labels {
56+
switch l.Name {
57+
case "Bug":
58+
assertLabelEqual(t, "Bug", "e11d21", "", l)
59+
case "documentation":
60+
assertLabelEqual(t, "Enhancement", "207de5", "", l)
61+
case "confirmed":
62+
assertLabelEqual(t, "Feature", "0052cc", "a feature request", l)
63+
case "enhancement":
64+
assertLabelEqual(t, "Invalid", "d4c5f9", "", l)
65+
case "critical":
66+
assertLabelEqual(t, "Question", "fbca04", "", l)
67+
case "discussion":
68+
assertLabelEqual(t, "Valid", "53e917", "", l)
69+
default:
70+
assert.Error(t, fmt.Errorf("unexpected label: %s", l.Name))
71+
}
72+
}
73+
74+
/*
75+
ToDo:
76+
GetAsset(relTag string, relID, id int64) (io.ReadCloser, error)
77+
GetMilestones() ([]*Milestone, error)
78+
GetReleases() ([]*Release, error)
79+
GetIssues(page, perPage int) ([]*Issue, bool, error)
80+
GetComments(issueNumber int64) ([]*Comment, error)
81+
GetPullRequests(page, perPage int) ([]*PullRequest, bool, error)
82+
GetReviews(pullRequestNumber int64) ([]*Review, error)
83+
*/
84+
85+
}

0 commit comments

Comments
 (0)