fix: Use mocked HTTP request
This commit is contained in:
parent
0606f05707
commit
6c506fc2f0
1 changed files with 22 additions and 4 deletions
|
@ -25,16 +25,22 @@ func TestPagureDownloadRepoWithPublicIssues(t *testing.T) {
|
|||
apiUser := os.Getenv("PAGURE_API_USER")
|
||||
apiPassword := os.Getenv("PAGURE_API_TOKEN")
|
||||
|
||||
cloneAddr := fmt.Sprintf("https://%s:%s@pagure.io/protop2g-test-srce.git", cloneUser, clonePassword)
|
||||
u, _ := url.Parse(cloneAddr)
|
||||
|
||||
fixtPath := "./testdata/pagure/full_download/unauthorized"
|
||||
server := unittest.NewMockWebServer(t, "https://pagure.io", fixtPath, false)
|
||||
defer server.Close()
|
||||
|
||||
serverURL, err := url.Parse(server.URL)
|
||||
require.NoError(t, err)
|
||||
|
||||
if clonePassword != "" || cloneUser != "" {
|
||||
serverURL.User = url.UserPassword(cloneUser, clonePassword)
|
||||
}
|
||||
serverURL.Path = "protop2g-test-srce.git"
|
||||
cloneAddr := serverURL.String()
|
||||
|
||||
factory := &PagureDownloaderFactory{}
|
||||
downloader, err := factory.New(t.Context(), base.MigrateOptions{
|
||||
CloneAddr: u.String(),
|
||||
CloneAddr: cloneAddr,
|
||||
AuthUsername: apiUser,
|
||||
AuthPassword: apiPassword,
|
||||
})
|
||||
|
@ -217,6 +223,7 @@ func TestPagureDownloadRepoWithPublicIssues(t *testing.T) {
|
|||
Closed: timePtr(time.Date(2025, time.May, 19, 6, 17, 11, 0, time.UTC)),
|
||||
MergedTime: timePtr(time.Date(2025, time.May, 19, 6, 17, 11, 0, time.UTC)),
|
||||
Merged: true,
|
||||
PatchURL: server.URL + "/protop2g-test-srce/pull-request/10.patch",
|
||||
Labels: []*base.Label{
|
||||
{
|
||||
Name: "ffff",
|
||||
|
@ -226,6 +233,7 @@ func TestPagureDownloadRepoWithPublicIssues(t *testing.T) {
|
|||
Ref: "test-ffff",
|
||||
SHA: "1a6ccc212aa958a0fe76155c2907c889969a7224",
|
||||
RepoName: "protop2g-test-srce",
|
||||
CloneURL: server.URL + "/protop2g-test-srce.git",
|
||||
},
|
||||
Base: base.PullRequestBranch{
|
||||
Ref: "main",
|
||||
|
@ -245,6 +253,7 @@ func TestPagureDownloadRepoWithPublicIssues(t *testing.T) {
|
|||
Closed: timePtr(time.Date(2025, time.May, 19, 6, 14, 3, 0, time.UTC)),
|
||||
MergedTime: timePtr(time.Date(2025, time.May, 19, 6, 14, 3, 0, time.UTC)),
|
||||
Merged: true,
|
||||
PatchURL: server.URL + "/protop2g-test-srce/pull-request/9.patch",
|
||||
Labels: []*base.Label{
|
||||
{
|
||||
Name: "eeee",
|
||||
|
@ -254,6 +263,7 @@ func TestPagureDownloadRepoWithPublicIssues(t *testing.T) {
|
|||
Ref: "test-eeee",
|
||||
SHA: "01b420e2964928a15f790f9b7c1a0053e7b5f0a5",
|
||||
RepoName: "protop2g-test-srce",
|
||||
CloneURL: server.URL + "/protop2g-test-srce.git",
|
||||
},
|
||||
Base: base.PullRequestBranch{
|
||||
Ref: "main",
|
||||
|
@ -273,6 +283,7 @@ func TestPagureDownloadRepoWithPublicIssues(t *testing.T) {
|
|||
Closed: timePtr(time.Date(2025, time.May, 5, 6, 54, 13, 0, time.UTC)),
|
||||
MergedTime: timePtr(time.Date(2025, time.May, 5, 6, 54, 13, 0, time.UTC)), // THIS IS WRONG
|
||||
Merged: false,
|
||||
PatchURL: server.URL + "/protop2g-test-srce/pull-request/8.patch",
|
||||
Labels: []*base.Label{
|
||||
{
|
||||
Name: "dddd",
|
||||
|
@ -282,6 +293,7 @@ func TestPagureDownloadRepoWithPublicIssues(t *testing.T) {
|
|||
Ref: "test-dddd",
|
||||
SHA: "0bc8b0c38e0790e9ef5c8d512a00b9c4dd048160",
|
||||
RepoName: "protop2g-test-srce",
|
||||
CloneURL: server.URL + "/protop2g-test-srce.git",
|
||||
},
|
||||
Base: base.PullRequestBranch{
|
||||
Ref: "main",
|
||||
|
@ -301,6 +313,7 @@ func TestPagureDownloadRepoWithPublicIssues(t *testing.T) {
|
|||
Closed: timePtr(time.Date(2025, time.May, 5, 6, 54, 3, 0, time.UTC)), // IT is CLOSED, Not MERGED so SHOULD NOT BE NIL
|
||||
MergedTime: timePtr(time.Date(2025, time.May, 5, 6, 54, 3, 0, time.UTC)), // THIS IS WRONG
|
||||
Merged: false,
|
||||
PatchURL: server.URL + "/protop2g-test-srce/pull-request/7.patch",
|
||||
Labels: []*base.Label{
|
||||
{
|
||||
Name: "cccc",
|
||||
|
@ -310,6 +323,7 @@ func TestPagureDownloadRepoWithPublicIssues(t *testing.T) {
|
|||
Ref: "test-cccc",
|
||||
SHA: "f1246e331cade9341b9e4f311b7a134f99893d21",
|
||||
RepoName: "protop2g-test-srce",
|
||||
CloneURL: server.URL + "/protop2g-test-srce.git",
|
||||
},
|
||||
Base: base.PullRequestBranch{
|
||||
Ref: "main",
|
||||
|
@ -329,6 +343,7 @@ func TestPagureDownloadRepoWithPublicIssues(t *testing.T) {
|
|||
Closed: timePtr(time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC)),
|
||||
MergedTime: timePtr(time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC)),
|
||||
Merged: false,
|
||||
PatchURL: server.URL + "/protop2g-test-srce/pull-request/6.patch",
|
||||
Labels: []*base.Label{
|
||||
{
|
||||
Name: "bbbb",
|
||||
|
@ -338,6 +353,7 @@ func TestPagureDownloadRepoWithPublicIssues(t *testing.T) {
|
|||
Ref: "test-bbbb",
|
||||
SHA: "2d40761dc53e6fa060ac49d88e1452c6751d4b1c",
|
||||
RepoName: "protop2g-test-srce",
|
||||
CloneURL: server.URL + "/protop2g-test-srce.git",
|
||||
},
|
||||
Base: base.PullRequestBranch{
|
||||
Ref: "main",
|
||||
|
@ -357,6 +373,7 @@ func TestPagureDownloadRepoWithPublicIssues(t *testing.T) {
|
|||
Closed: timePtr(time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC)),
|
||||
MergedTime: timePtr(time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC)),
|
||||
Merged: false,
|
||||
PatchURL: server.URL + "/protop2g-test-srce/pull-request/5.patch",
|
||||
Labels: []*base.Label{
|
||||
{
|
||||
Name: "aaaa",
|
||||
|
@ -366,6 +383,7 @@ func TestPagureDownloadRepoWithPublicIssues(t *testing.T) {
|
|||
Ref: "test-aaaa",
|
||||
SHA: "b55e5c91d2572d60a8d7e71b3d3003e523127bd4",
|
||||
RepoName: "protop2g-test-srce",
|
||||
CloneURL: server.URL + "/protop2g-test-srce.git",
|
||||
},
|
||||
Base: base.PullRequestBranch{
|
||||
Ref: "main",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue