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 RepoCollab client #1051

Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Octokit;
using Octokit.Tests.Integration;
using Xunit;
using Octokit.Tests.Integration.Helpers;

public class RepositoryCollaboratorClientTests
{
public class TheGetAllMethod
{
[IntegrationTest]
public async Task ReturnsAllCollaborators()
{
var github = Helper.GetAuthenticatedClient();
var repoName = Helper.MakeNameWithTimestamp("public-repo");

using (var context = await github.CreateRepositoryContext(new NewRepository(repoName)))
{
var fixture = github.Repository.Collaborator;

// add a collaborator
await fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests");

var collaborators = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName);
Assert.NotNull(collaborators);
Assert.Equal(2, collaborators.Count);
}

}
}

public class TheIsCollaboratorMethod
{
[IntegrationTest]
public async Task ReturnsTrueIfUserIsCollaborator()
{
var github = Helper.GetAuthenticatedClient();
var repoName = Helper.MakeNameWithTimestamp("public-repo");

using (var context = await github.CreateRepositoryContext(new NewRepository(repoName)))
{
var fixture = github.Repository.Collaborator;

// add a collaborator
fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests");

var isCollab = await fixture.IsCollaborator(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests");

Assert.True(isCollab);
}
}
}
}
1 change: 1 addition & 0 deletions Octokit.Tests.Integration/Octokit.Tests.Integration.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
<Compile Include="Reactive\ObservableUserEmailsClientTests.cs" />
<Compile Include="Reactive\ObservableTeamsClientTests.cs" />
<Compile Include="RedirectTests.cs" />
<Compile Include="Clients\RepositoryCollaboratorClientTests.cs" />
<Compile Include="SelfTests.cs" />
</ItemGroup>
<ItemGroup>
Expand Down