Skip to content
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

Repositories.GetCommitSHA1 doesn't work as expected #39

Closed
liranelisha opened this issue Oct 13, 2022 · 5 comments · Fixed by #40
Closed

Repositories.GetCommitSHA1 doesn't work as expected #39

liranelisha opened this issue Oct 13, 2022 · 5 comments · Fixed by #40

Comments

@liranelisha
Copy link

I'm starting to use this awesome mock package, and doing some tests on the different endpoints
I've notices that i can mock client.Repositories.GetCommitSHA1 using the GetReposCommitsByOwnerByRepoByRef. At first it worked great, but once i've started to send more complex ref it fell apart.
for example

sha, resp, err := ghClient.Repositories.GetCommitSHA1(context.Background(), "gg", "mocked-repo-2", "refs/heads/ddd", "")
panics out. this is due to the /heads/ddd is added to the endpoint, and so i'm guessing is not get picked up by the mock implementation....
currently i've manually added

mockSha := mock.EndpointPattern{
  Pattern: "/repos/{owner}/{repo}/commits/{ref}/heads/{x}",
  Method:  "GET",
}

but it could be nice if the mock package can solve this

@migueleliasweb
Copy link
Owner

Hi @liranelisha ,

I think I know what the problem is. It should be an easy fix.

Let me check a couple of things.

Possibly related to last parameters having a forward slash like in: #26

@migueleliasweb
Copy link
Owner

migueleliasweb commented Oct 13, 2022

Hi @liranelisha , I've found the problem.

It was due to the way GH matches request params in the URL. It was a smal change as I knew these edge cases would happen.

I'm just finishing implementing some unittests.

@migueleliasweb
Copy link
Owner

@liranelisha Could you try to use this branch to see if it fixes your problem? #40

The real change was: https://github.com/migueleliasweb/go-github-mock/pull/40/files#diff-de3bdf480ea16b407da4a65310f90bc74c077b9f15f2cfcb54d509c1d65cb894R13

@liranelisha
Copy link
Author

pass with flying colors :)
image

@migueleliasweb
Copy link
Owner

Cool, I will create a new release 👍

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 a pull request may close this issue.

2 participants