Skip to content

Commit

Permalink
fix: updating gitea demo url
Browse files Browse the repository at this point in the history
apparently we sometimes send requests to the demo site in the tests. These have now failed since https://try.gitea.io is gone. Replacing with https://demo.gitea.com that actually works
  • Loading branch information
msvticket committed Oct 10, 2024
1 parent 7a98a89 commit 635708f
Show file tree
Hide file tree
Showing 12 changed files with 141 additions and 141 deletions.
18 changes: 9 additions & 9 deletions scm/driver/gitea/content_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ func TestContentFind(t *testing.T) {
defer gock.Off()

mockServerVersion()
gock.New("https://try.gitea.io").
gock.New("https://demo.gitea.com").
Get("/api/v1/repos/go-gitea/gitea/contents/.gitignore").
Reply(200).
Type("application/json;charset=utf-8").
File("testdata/content_find.json")

client, _ := New("https://try.gitea.io")
client, _ := New("https://demo.gitea.com")
result, _, err := client.Contents.Find(
context.Background(),
"go-gitea/gitea",
Expand Down Expand Up @@ -58,13 +58,13 @@ func TestContentList(t *testing.T) {
defer gock.Off()

mockServerVersion()
gock.New("https://try.gitea.io").
gock.New("https://demo.gitea.com").
Get("/api/v1/repos/go-gitea/gitea/contents/").
Reply(200).
Type("application/json;charset=utf-8").
File("testdata/content_list.json")

client, _ := New("https://try.gitea.io")
client, _ := New("https://demo.gitea.com")
result, _, err := client.Contents.List(
context.Background(),
"go-gitea/gitea",
Expand Down Expand Up @@ -97,7 +97,7 @@ func TestContentCreate(t *testing.T) {
c := encode(content)

r :=
gock.New("https://try.gitea.io").
gock.New("https://demo.gitea.com").
Post("/api/v1/repos/go-gitea/gitea/contents/README.md").
JSON(map[string]interface{}{
"message": message,
Expand All @@ -121,7 +121,7 @@ func TestContentCreate(t *testing.T) {
Branch: branch,
Message: message,
}
client, _ := New("https://try.gitea.io")
client, _ := New("https://demo.gitea.com")
_, err := client.Contents.Create(context.Background(), "go-gitea/gitea", "README.md", o)
if err != nil {
t.Error(err)
Expand All @@ -139,7 +139,7 @@ func TestContentUpdate(t *testing.T) {
message := "add README.md"
branch := "master"

r := gock.New("https://try.gitea.io").
r := gock.New("https://demo.gitea.com").
Put("/api/v1/repos/go-gitea/gitea/contents/README.md").
MatchType("json").
JSON(map[string]interface{}{
Expand All @@ -166,7 +166,7 @@ func TestContentUpdate(t *testing.T) {
Message: message,
Sha: previousSHA,
}
client, _ := New("https://try.gitea.io")
client, _ := New("https://demo.gitea.com")
_, err := client.Contents.Update(context.Background(), "go-gitea/gitea", "README.md", o)
if err != nil {
t.Error(err)
Expand All @@ -176,7 +176,7 @@ func TestContentUpdate(t *testing.T) {
func TestContentDelete(t *testing.T) {
// TODO disable for now as its down
t.SkipNow()
client, _ := New("https://try.gitea.io")
client, _ := New("https://demo.gitea.com")
_, err := client.Contents.Delete(context.Background(), "go-gitea/gitea", "README.md", &scm.ContentParams{Ref: "master"})
if err != scm.ErrNotSupported {
t.Errorf("Expect Not Supported error")
Expand Down
26 changes: 13 additions & 13 deletions scm/driver/gitea/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ func TestCommitFind(t *testing.T) {

mockServerVersion()

gock.New("https://try.gitea.io").
gock.New("https://demo.gitea.com").
Get("/api/v1/repos/gitea/gitea/git/commits/c43399cad8766ee521b873a32c1652407c5a4630").
Reply(200).
Type("application/json").
File("testdata/commit.json")

client, _ := New("https://try.gitea.io")
client, _ := New("https://demo.gitea.com")
got, _, err := client.Git.FindCommit(
context.Background(),
"gitea/gitea",
Expand Down Expand Up @@ -60,13 +60,13 @@ func TestCommitList(t *testing.T) {

mockServerVersion()

gock.New("https://try.gitea.io").
gock.New("https://demo.gitea.com").
Get("/api/v1/repos/go-gitea/gitea/commits").
Reply(200).
Type("application/json").
File("testdata/commits.json")

client, _ := New("https://try.gitea.io")
client, _ := New("https://demo.gitea.com")
got, _, err := client.Git.ListCommits(context.Background(), "go-gitea/gitea", scm.CommitListOptions{})
if err != nil {
t.Error(err)
Expand All @@ -84,15 +84,15 @@ func TestCommitList(t *testing.T) {
}

func TestChangeList(t *testing.T) {
client, _ := New("https://try.gitea.io")
client, _ := New("https://demo.gitea.com")
_, _, err := client.Git.ListChanges(context.Background(), "go-gitea/gitea", "f05f642b892d59a0a9ef6a31f6c905a24b5db13a", &scm.ListOptions{})
if err != scm.ErrNotSupported {
t.Errorf("Expect Not Supported error")
}
}

func TestCompareCommits(t *testing.T) {
client, _ := New("https://try.gitea.io")
client, _ := New("https://demo.gitea.com")
_, _, err := client.Git.CompareCommits(context.Background(), "go-gitea/gitea", "21cf205dc770d637a9ba636644cf8bf690cc100d", "63aeb0a859499623becc1d1e7c8a2ad57439e139", &scm.ListOptions{})
if err != scm.ErrNotSupported {
t.Errorf("Expect Not Supported error")
Expand All @@ -108,13 +108,13 @@ func TestBranchFind(t *testing.T) {

mockServerVersion()

gock.New("https://try.gitea.io").
gock.New("https://demo.gitea.com").
Get("/api/v1/repos/go-gitea/gitea/branches/master").
Reply(200).
Type("application/json").
File("testdata/branch.json")

client, _ := New("https://try.gitea.io")
client, _ := New("https://demo.gitea.com")
got, _, err := client.Git.FindBranch(context.Background(), "go-gitea/gitea", "master")
if err != nil {
t.Error(err)
Expand All @@ -138,14 +138,14 @@ func TestBranchList(t *testing.T) {

mockServerVersion()

gock.New("https://try.gitea.io").
gock.New("https://demo.gitea.com").
Get("/api/v1/repos/go-gitea/gitea/branches").
Reply(200).
Type("application/json").
SetHeaders(mockPageHeaders).
File("testdata/branches.json")

client, _ := New("https://try.gitea.io")
client, _ := New("https://demo.gitea.com")
got, res, err := client.Git.ListBranches(context.Background(), "go-gitea/gitea", &scm.ListOptions{})
if err != nil {
t.Error(err)
Expand All @@ -171,7 +171,7 @@ func TestBranchList(t *testing.T) {
//

func TestTagFind(t *testing.T) {
client, _ := New("https://try.gitea.io")
client, _ := New("https://demo.gitea.com")
_, _, err := client.Git.FindTag(context.Background(), "go-gitea/gitea", "v1.0.0")
if err != scm.ErrNotSupported {
t.Errorf("Expect Not Supported error")
Expand All @@ -183,14 +183,14 @@ func TestTagList(t *testing.T) {

mockServerVersion()

gock.New("https://try.gitea.io").
gock.New("https://demo.gitea.com").
Get("/api/v1/repos/go-gitea/gitea/tags").
Reply(200).
Type("application/json").
SetHeaders(mockPageHeaders).
File("testdata/tags.json")

client, _ := New("https://try.gitea.io")
client, _ := New("https://demo.gitea.com")
got, res, err := client.Git.ListTags(context.Background(), "go-gitea/gitea", &scm.ListOptions{})
if err != nil {
t.Error(err)
Expand Down
18 changes: 9 additions & 9 deletions scm/driver/gitea/gitea_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ import (
)

var mockPageHeaders = map[string]string{
"Link": `<https://try.gitea.io/v1/resource?page=2>; rel="next",` +
`<https://try.gitea.io/v1/resource?page=1>; rel="prev",` +
`<https://try.gitea.io/v1/resource?page=1>; rel="first",` +
`<https://try.gitea.io/v1/resource?page=5>; rel="last"`,
"Link": `<https://demo.gitea.com/v1/resource?page=2>; rel="next",` +
`<https://demo.gitea.com/v1/resource?page=1>; rel="prev",` +
`<https://demo.gitea.com/v1/resource?page=1>; rel="first",` +
`<https://demo.gitea.com/v1/resource?page=5>; rel="last"`,
}

func TestClient(t *testing.T) {
defer gock.Off()

mockServerVersion()

client, err := New("https://try.gitea.io")
client, err := New("https://demo.gitea.com")
if err != nil {
t.Error(err)
}
if got, want := client.BaseURL.String(), "https://try.gitea.io/"; got != want {
if got, want := client.BaseURL.String(), "https://demo.gitea.com/"; got != want {
t.Errorf("Want Client URL %q, got %q", want, got)
}
}
Expand All @@ -38,11 +38,11 @@ func TestClient_Base(t *testing.T) {

mockServerVersion()

client, err := New("https://try.gitea.io/v1")
client, err := New("https://demo.gitea.com/v1")
if err != nil {
t.Error(err)
}
if got, want := client.BaseURL.String(), "https://try.gitea.io/v1/"; got != want {
if got, want := client.BaseURL.String(), "https://demo.gitea.com/v1/"; got != want {
t.Errorf("Want Client URL %q, got %q", want, got)
}
}
Expand Down Expand Up @@ -76,7 +76,7 @@ func testPage(res *scm.Response) func(t *testing.T) {
}

func mockServerVersion() {
gock.New("https://try.gitea.io").
gock.New("https://demo.gitea.com").
Get("/api/v1/version").
Reply(200).
Type("application/json").
Expand Down
Loading

0 comments on commit 635708f

Please sign in to comment.