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

Add overloads to specify branch for ContentRequest #1093

Merged
merged 5 commits into from
Feb 11, 2016

Conversation

M-Zuber
Copy link
Contributor

@M-Zuber M-Zuber commented Feb 4, 2016

Fixes #958

@@ -91,6 +116,18 @@ public CreateFileRequest(string message, string content) : base(message)
}

/// <summary>
/// Initializes a new instance of the <see cref="DeleteFileRequest"/> class.
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo in the xml doc with the cref to the class name

@ryangribble
Copy link
Contributor

Hey @M-Zuber
This should be an awesome function, a tool we are writing at the moment has a need to push a file directly into a specific branch too 😀

I noticed one typo of a class name in XmlDoc comments, ive flagged above.

Also could I suggest ensuring we keep the tests up to date with at least these 2 items?

  • update the unit tests to cover off the addition of the new branch parameter
  • add an integration test to prove it actually creates the file on the specified branch

Let me know if you want some help adding the tests

@M-Zuber
Copy link
Contributor Author

M-Zuber commented Feb 5, 2016

Thank you for catching the typo!
I should be able to add unit tests after the weekend.

Would you test anything in the unit tests other then that the correct url was called?

The integration test can create, update, and then delete a file on the same branch. Sounds good to you?

@ryangribble
Copy link
Contributor

Yeah if you look at the "crud" integration test I'd probably do the same actions as that, but specifying a named branch

For unit test since the url is the same anyway, you could check that the CreateFileRequest object passed through, has the correct path/message/content/branch present in it. Eg have look at PassesRequestObject() test here

@M-Zuber
Copy link
Contributor Author

M-Zuber commented Feb 8, 2016

I wasn't able to get the unit tests to work, hopefully the integration test will be enough

@ryangribble
Copy link
Contributor

Hey @M-Zuber that looks good... your integration test is passing for me here.

On the topic of unit tests, your change was mostly to a Request object and it doesnt look like there are many unit tests of those things in octokit.net.

However if you are interested, I did just send you a pull request that implements unit tests on the CreateFile() DeleteFile() and UpdateFile() calls in RepositoryClient, including making sure your new branch field is correctly passed through to the underlying ApiClient. What ive found with Octokit unit tests for API clients typically check

  • calls the correct URL
  • passes through the request object
  • checks parameters for nulls and throws exceptions if paramter is required

M-Zuber#2

new DeleteFileRequest("Deleted file", fileSha, branchName));

await Assert.ThrowsAsync<NotFoundException>(
async () => await fixture.GetAllContents(repository.Owner.Login, repository.Name, "somefile.txt"));
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this state machine is necessary. Assert.ThrowsAsync expects a Task, which GetAllContents already returns 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy paste error 😄
Will fix when I'm back by a machine.

It is needed. If removed the test completes, but fails with a message that no error was thrown.
EDIT: Drunk VS had me today/

@M-Zuber
Copy link
Contributor Author

M-Zuber commented Feb 8, 2016

@ryangribble thank you for the PR. I asked a question there.

Add unit tests for CreateFile DeleteFile and UpdateFile
@Thwaitesy
Copy link

@ryangribble when do you think this will be merged?

@ryangribble
Copy link
Contributor

I don't have commit rights, am sitting on a few pending PR's myself 😀

@shiftkey
Copy link
Member

shiftkey commented Feb 9, 2016

@Thwaitesy @ryangribble apologies for the delay, I'm aiming to get through these by the end of the week. Thankfully we just did a big release, so the next one should be a bit easier to manage...

@shiftkey
Copy link
Member

Code looks good, tests all pass, and it got a pretty great review too...

shiftkey added a commit that referenced this pull request Feb 11, 2016
Add overloads to specify branch for ContentRequest
@shiftkey shiftkey merged commit d7d7907 into octokit:master Feb 11, 2016
@M-Zuber
Copy link
Contributor Author

M-Zuber commented Feb 11, 2016

YAY!! I got a Stevie!! 😀

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.

5 participants