mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-05-25 15:42:55 +00:00
d02007d2b6
Ensure Teams.GetAllRepositories() calls pass the preview header and add integration tests to assert the permissions property is populated
67 lines
2.0 KiB
C#
67 lines
2.0 KiB
C#
using System.Linq;
|
|
using System.Reactive.Linq;
|
|
using System.Threading.Tasks;
|
|
using Octokit;
|
|
using Octokit.Reactive;
|
|
using Octokit.Tests.Integration;
|
|
using Octokit.Tests.Integration.Helpers;
|
|
using Xunit;
|
|
|
|
public class ObservableTeamsClientTests
|
|
{
|
|
public class TheGetAllMembersMethod
|
|
{
|
|
readonly Team _team;
|
|
|
|
public TheGetAllMembersMethod()
|
|
{
|
|
var github = Helper.GetAuthenticatedClient();
|
|
|
|
_team = github.Organization.Team.GetAll(Helper.Organization).Result.First();
|
|
}
|
|
|
|
[OrganizationTest]
|
|
public async Task GetsAllMembersWhenAuthenticated()
|
|
{
|
|
var github = Helper.GetAuthenticatedClient();
|
|
var client = new ObservableTeamsClient(github);
|
|
|
|
var observable = client.GetAllMembers(_team.Id, ApiOptions.None);
|
|
var members = await observable.ToList();
|
|
|
|
Assert.True(members.Count > 0);
|
|
Assert.True(members.Any(x => x.Login == Helper.UserName));
|
|
}
|
|
}
|
|
|
|
public class TheGetAllRepositoriesMethod
|
|
{
|
|
readonly Team _team;
|
|
|
|
public TheGetAllRepositoriesMethod()
|
|
{
|
|
var github = Helper.GetAuthenticatedClient();
|
|
|
|
_team = github.Organization.Team.GetAll(Helper.Organization).Result.First();
|
|
}
|
|
|
|
[OrganizationTest]
|
|
public async Task GetsAllRepositories()
|
|
{
|
|
var github = Helper.GetAuthenticatedClient();
|
|
var client = new ObservableTeamsClient(github);
|
|
|
|
using (var repositoryContext = await github.CreateRepositoryContext(Helper.Organization, new NewRepository(Helper.MakeNameWithTimestamp("teamrepo"))))
|
|
{
|
|
client.AddRepository(_team.Id, Helper.Organization, repositoryContext.RepositoryName);
|
|
|
|
var observable = client.GetAllRepositories(_team.Id, ApiOptions.None);
|
|
var repos = await observable.ToList();
|
|
|
|
Assert.True(repos.Count() > 0);
|
|
Assert.NotNull(repos[0].Permissions);
|
|
}
|
|
}
|
|
}
|
|
}
|