Skip to content

Commit

Permalink
finish integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
martinscholz83 committed Jun 8, 2016
1 parent 6e03a81 commit 82dce21
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions Octokit.Tests.Integration/Clients/TeamsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,24 +123,37 @@ public async Task GetsAllMembersWhenAuthenticated()

public class TheAddOrUpdateTeamRepositoryMethod
{
readonly Team team;
private readonly TeamContext _teamContext;
private readonly IGitHubClient _github;

public TheAddOrUpdateTeamRepositoryMethod()
{
_github = EnterpriseHelper.GetAuthenticatedClient();
var newTeam = new NewTeam(Guid.NewGuid().ToString());
_teamContext = _github.CreateTeamContext(EnterpriseHelper.Organization, newTeam).Result;
}

[OrganizationTest]
public async Task CanAddRepository()
{
var github = Helper.GetAuthenticatedClient();

var repoName = Helper.MakeNameWithTimestamp("public-repo");

var team = github.Organization.Team.GetAll(Helper.Organization).Result.First();
var team = _teamContext.Team;

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

var addRepo = await github.Organization.Team.AddRepository(team.Id, team.Organization.Name, createdRepository.Name, new RepositoryPermissionRequest(Permission.Admin));
var addRepo = await _github.Organization.Team.AddRepository(team.Id, team.Organization.Name, createdRepository.Name, new RepositoryPermissionRequest(Permission.Admin));

Assert.True(addRepo);

var addedRepo = await _github.Organization.Team.GetAllRepositories(team.Id);

//Check if permission was correctly applied
Assert.True(addedRepo.First(x => x.Id == createdRepository.Id).Permissions.Admin == true);


Assert.NotNull(addRepo);
}
}
}
Expand Down

0 comments on commit 82dce21

Please sign in to comment.