-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
New method on RepositoryCommits client - Get the sha1 of a commit reference #1195
Conversation
Updated RepositoryCommitsClients and unit/integration tests
Added implementation for Reactive framework
/// <param name="name">The name of the repository</param> | ||
/// <param name="reference">The repository reference</param> | ||
/// <returns></returns> | ||
Task<string> Sha1(string owner, string name, string reference); |
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.
Could we add a verb to this method? Say something like GetSha1
?
@rogertinsley welcome! To be perfectly honest, the only bits of feedback I have are minor - this is really nice work! One suggestion - if you wanted to add another integration test where you:
I think that'll give us enough coverage for this endpoint to close this out. |
Thanks @shiftkey, I'll make the changes that you've suggested 👍 |
public class TheSha1Method | ||
{ | ||
[Fact] | ||
public async Task EnsureNonNullArguments() |
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.
Minor note that the wording should be "Ensures" rather than "Ensure". Since the test shoudl read TheGetSha1Method.EnsuresNonNullArguments() 😀
Also this test is checking Null and Empty arguments. In other places ive seen us implement this as 2 test methods eg EnsuresNonNullArguments()
and EnsuresNonEmptyArguments()
Great first contribution 👏 I agree with @shiftkey regarding adding verb for I've also raised one minor nitpick on consistency/wording in the tests |
- Create repository - Call GetSha1 - Call it a second time - Verify the two responses are equal
- One unit test for NonNullArguments - Another unit test for NonEMptyArguments
👏 Nice stuff! |
I've made the changes you both have suggested. Are you happy with the integration test approach? I've used a similar approach to other tests in the same class, that is to use |
public class TheSha1Method | ||
{ | ||
[Fact] | ||
public async void EnsuresNonNullArguments() |
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.
Make this async Task
as this is more test-runner friendly...
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.
And the CI test won't fail like it currently is...
- CreateTheWorld now returns a Task<Reference> - This reference is compared with client.GetSha1
I've updated |
@@ -790,5 +790,40 @@ public void GetsCorrectUrl() | |||
await Assert.ThrowsAsync<ArgumentException>(() => client.EditBranch("owner", "repo", "", update)); | |||
} | |||
} | |||
|
|||
public class TheSha1Method |
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.
Should be TheGetSha1Method
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.
Thanks - updated it, I'm getting there 😄
This looks good! But I noticed there are no Unit or Integration tests for the I realise this was like that before this PR... Some parts of the code base (particularly observable implementations) don't have tests around them, but as we touch these areas ideally we should start to correct that problem. Without tests there really could be something lurking in there making the observable implementation not work and we dont want to find out from end users if possible! So at a minimum, I'd like to see tests added for the Observable If you have a look at some existing examples of Observable client unit and integration tests you will find that the unit tests of observable would have a Im not sure where @shiftkey stands on integration tests for observable clients - given that alot are missing, and it's pretty much only ever calling the regular client anyway... perhaps all we need are unit tests for observable clients... But in my contributions I do typically add integration tests, I pretty much copy/paste the regular client test, modify it to use the observable client and also like to write it as per below, so it's obvious the item is an observable (eventhough you could simply var observable = _fixture.GetSha1(x,x,x);
var sha1 = await observable; |
Added tests for GetSha1
Added integration test for GetSha1 for observableclient
Check the ctor for a null IGitHubClient
I've added unit and integrations tests for the |
This is essentially my views - if the implementation is just calling the |
Oops! Looks like just a minor issue there with the "NotNull" test checking empty strings, and the "NonEmpty" test checking nulls! If you can just fix that up we are good to go Also given @shiftkey's comment let's ditch the integration test for the observable implementation, since it's just calling the real client anyway. SORRY! |
NoNull needs to test null strings and NonEmpty tests empty strings
No problem - I've removed the integration test and updated the unit test. I've learnt a lot about the codebase and how to contribute with this PR and you guys haven't scared me off either 😁 so I'm going to pick up some more |
@rogertinsley this all looks good! I can't wait for the next one. I'll let @ryangribble have the final word. |
New method on RepositoryCommits client - Get the sha1 of a commit reference
Title
New method on RepositoryCommits client - Get the sha1 of a commit reference. Fixes #1189
Description
This is my first foray into contributing to OSS. Any feedback is greatly appreciated.