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 integration tests for GetLatestRelease #1090

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions Octokit.Tests.Integration/Clients/ReleasesClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,36 @@ public void Dispose()
_context.Dispose();
}
}

public class TheGetLatestReleaseMethod
{
private readonly IReleasesClient _releaseClient;
private readonly IGitHubClient _client;

public TheGetLatestReleaseMethod()
{
_client = Helper.GetAuthenticatedClient();
_releaseClient = _client.Repository.Release;
}

[IntegrationTest]
public async Task ReturnsLatestRelease()
{
var lastReleaseFromGetAll = (await _releaseClient.GetAll("octokit", "octokit.net")).OrderBy(r => r.CreatedAt).Last();
var lastRelease = await _releaseClient.GetLatest("octokit", "octokit.net");

Assert.Equal(lastReleaseFromGetAll.Id, lastRelease.Id);
}

[IntegrationTest]
public async Task NoReleaseOnRepo()
{
var repoName = Helper.MakeNameWithTimestamp("public-repo");
await _client.Repository.Create(new NewRepository(repoName));

await Assert.ThrowsAsync<NotFoundException>(() => _releaseClient.GetLatest(Helper.UserName, repoName));

await _client.Repository.Delete(Helper.UserName, repoName);
}
}
}