Skip to content

Fix regression in github enterprise url handling #40#41

Open
luna-veil-8080 wants to merge 1 commit intojferrl:mainfrom
luna-veil-8080:main
Open

Fix regression in github enterprise url handling #40#41
luna-veil-8080 wants to merge 1 commit intojferrl:mainfrom
luna-veil-8080:main

Conversation

@luna-veil-8080
Copy link

Description

Resolves #40

Type of Change

Please delete options that are not relevant.

  • 🐛 Bug fix (non-breaking change which fixes an issue)

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this change manually

Documentation

  • I have updated the documentation accordingly
  • I have updated the CHANGELOG.md file
  • I have added/updated code comments where necessary

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • I have checked my code and corrected any misspellings
  • My changes are compatible with the supported Go versions (1.21+)

Screenshots (if applicable)

If your changes include visual elements, please add screenshots here.

Related Issues

Closes #(issue number)

Additional Notes

Add any other context about the pull request here.

Copy link
Owner

@jferrl jferrl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, review comments. 😃

wantErr bool
name string
baseURL string
expectedBaseURL interface{}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer keeping the original wantErr bool + a separate expectedURL string field instead of using interface{} to represent both. This is more idiomatic Go and gives type safety at compile time.

@@ -12,33 +12,48 @@ import (

func Test_githubClient_withEnterpriseURL(t *testing.T) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add test cases for the remaining branches?

https://github.example.com/api/v3/ — already fully suffixed, should stay as-is
https://ghes.api.example.com — .api. in host, should skip /api/v3/ append
https://github.example.com/ — trailing slash already present, should not double it

t.Errorf("withEnterpriseURL() error = %v, wantErr %v", err, tt.wantErr)
githubClient, err := client.withEnterpriseURL(tt.baseURL)

if err != nil {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This silently passes when an error occurs and expectedBaseURL is nil, but doesn't assert that an error was expected. The original if (err != nil) != tt.wantErr pattern is stricter — it catches both unexpected errors and missing expected errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Wrong url for github enterprise since go-github dependency was removed

2 participants