-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix graphql client creation when only v3 url is given #103
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, but you could rewrite this as
v4URL = strings.TrimSuffix(source.GitHubAPIURL, "/v3/") + "/graphql"
if you get rid of thesource.GitHubAPIURL += "/"
above (which seems unnecessary?)also, perhaps we could add a test for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First part sounds good, I'll change that.
For the testing, I looked into that before writing the code and found that I couldn't test this part specifically, verifying that the v4 API url is generated correctly.
Ideally I would verify that the
githubv4.Client
was given the correct URL. I can do this easily with the v3 client: https://github.com/google/go-github/blob/c2c4a6d477016a3e73a63d67b1933fb24f52fd99/github/github.go#L140-L143But this is not possible to check with the v4 client, it hides the
graphql.client
which contains the URL we'd want to check: https://github.com/shurcooL/githubv4/blob/234843c633fadff9694210ce7ab97948c9148a14/githubv4.go#L11-L13Also, there's only one test for this function to see that it returns an error in one case. After learning all that I decided it wasn't worth adding a test :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be possible, though haven't tried - we validate the path that we receive the request at, so we could set up the
GitHubAPIURL
ashttp://some-host:1234/v3
and validate it strips the v3 in the requestSetup:
github-release-resource/github_test.go
Line 126 in c82c11c
Assert:
github-release-resource/github_test.go
Line 168 in c82c11c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I just thought of a way to check that the URL's it uses are correct! I can use the ghttp.Server to see what endpoints it is hitting. I'll see how hard that is to do, probably not very.
EDIT: I wrote this before seeing your reply, it didn't load for whatever reason :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added tests for it! and ensured they failed with the original code as well.