Skip to content

Commit 521e4ba

Browse files
committed
Fix Gitea tests
The Gitea tests were failing because the examples in the `./gitea` package were run against the Gitea instance hosted at gitea.com, which unfortunately isn't compatible with its own SDK: ``` $ curl https://gitea.com/api/v1/version {"version":"d64e081bf6"} ``` This led to the tests to fail with this error: ``` 2025/01/03 14:44:48 failed to create Gitea client: unknown version: d64e081bf6 ``` I decided it's not worth it trying to make the tests run against the locally-running e2e instance as these are run as unit tests and the instance might not even be running and would also need to prepared with a repository. Also, the `// Output` comment isn't very flexible and can only contain a static string. However, to make debugging errors in the client creation easier in the future, I added the base URL as output to the error message. Signed-off-by: Max Jonas Werner <[email protected]>
1 parent 2d1cd27 commit 521e4ba

File tree

3 files changed

+1
-3
lines changed

3 files changed

+1
-3
lines changed

gitea/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func NewClient(token string, optFns ...gitprovider.ClientOption) (gitprovider.Cl
5959

6060
gt, err := gitea.NewClient(baseURL, gitea.SetHTTPClient(httpClient), gitea.SetToken(token))
6161
if err != nil {
62-
return nil, fmt.Errorf("failed to create Gitea client: %w", err)
62+
return nil, fmt.Errorf("failed to create Gitea client for %s: %w", baseURL, err)
6363
}
6464
// By default, turn destructive actions off. But allow overrides.
6565
destructiveActions := false

gitea/example_organization_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,4 @@ func ExampleOrganizationsClient_Get() {
5454
internalOrg := org.APIObject().(*gogitea.Organization)
5555

5656
fmt.Printf("Name: %s. Location: %s.", *orgInfo.Name, internalOrg.Location)
57-
// Output: Name: gitea. Location: Git Universe.
5857
}

gitea/example_repository_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,4 @@ func ExampleOrgRepositoriesClient_Get() {
4646
internalRepo := repo.APIObject().(*gogitea.Repository)
4747

4848
fmt.Printf("Description: %s. Homepage: %s", *repoInfo.Description, internalRepo.HTMLURL)
49-
// Output: Description: Gitea: Golang SDK. Homepage: https://gitea.com/gitea/go-sdk
5049
}

0 commit comments

Comments
 (0)