Remove the obsolete branch protection methods and classes as they are now no longer supported (#1620)

This commit is contained in:
Ryan Gribble
2017-06-26 22:10:17 +10:00
committed by GitHub
parent 5ee4d64046
commit 98dfd77142
17 changed files with 0 additions and 774 deletions
@@ -1478,12 +1478,6 @@ public class RepositoriesClientTests
var branches = await github.Repository.GetAllBranches(7528679);
Assert.NotEmpty(branches);
// Ensure Protection attribute is deserialized
foreach (var branch in branches)
{
Assert.NotNull(branch.Protection);
}
}
[IntegrationTest]
@@ -1798,102 +1792,4 @@ public class RepositoriesClientTests
Assert.NotEqual(firstPage[4].Name, secondPage[4].Name);
}
}
public class TheEditBranchMethod
{
private readonly IRepositoriesClient _fixture;
private readonly RepositoryContext _context;
public TheEditBranchMethod()
{
var github = Helper.GetAuthenticatedClient();
_context = github.CreateRepositoryContext("source-repo").Result;
_fixture = github.Repository;
}
public async Task CreateTheWorld()
{
// Set master branch to be protected, with some status checks
var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Everyone, new List<string> { "check1", "check2" });
var update = new BranchUpdate();
update.Protection = new BranchProtection(true, requiredStatusChecks);
var newBranch = await _fixture.EditBranch(_context.Repository.Owner.Login, _context.Repository.Name, "master", update);
}
[IntegrationTest]
public async Task ProtectsBranch()
{
// Set master branch to be protected, with some status checks
var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Everyone, new List<string> { "check1", "check2", "check3" });
var update = new BranchUpdate();
update.Protection = new BranchProtection(true, requiredStatusChecks);
var branch = await _fixture.EditBranch(_context.Repository.Owner.Login, _context.Repository.Name, "master", update);
// Ensure a branch object was returned
Assert.NotNull(branch);
// Retrieve master branch
branch = await _fixture.GetBranch(_context.Repository.Owner.Login, _context.Repository.Name, "master");
// Assert the changes were made
Assert.Equal(branch.Protection.Enabled, true);
Assert.Equal(branch.Protection.RequiredStatusChecks.EnforcementLevel, EnforcementLevel.Everyone);
Assert.Equal(branch.Protection.RequiredStatusChecks.Contexts.Count, 3);
}
[IntegrationTest]
public async Task RemoveStatusCheckEnforcement()
{
await CreateTheWorld();
// Remove status check enforcement
var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Off, new List<string> { "check1" });
var update = new BranchUpdate();
update.Protection = new BranchProtection(true, requiredStatusChecks);
var branch = await _fixture.EditBranch(_context.Repository.Owner.Login, _context.Repository.Name, "master", update);
// Ensure a branch object was returned
Assert.NotNull(branch);
// Retrieve master branch
branch = await _fixture.GetBranch(_context.Repository.Owner.Login, _context.Repository.Name, "master");
// Assert the changes were made
Assert.Equal(branch.Protection.Enabled, true);
Assert.Equal(branch.Protection.RequiredStatusChecks.EnforcementLevel, EnforcementLevel.Off);
Assert.Equal(branch.Protection.RequiredStatusChecks.Contexts.Count, 1);
}
[IntegrationTest]
public async Task UnprotectsBranch()
{
await CreateTheWorld();
// Unprotect branch
// Deliberately set Enforcement and Contexts to some values (these should be ignored)
var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Everyone, new List<string> { "check1" });
var update = new BranchUpdate();
update.Protection = new BranchProtection(false, requiredStatusChecks);
var branch = await _fixture.EditBranch(_context.Repository.Owner.Login, _context.Repository.Name, "master", update);
// Ensure a branch object was returned
Assert.NotNull(branch);
// Retrieve master branch
branch = await _fixture.GetBranch(_context.Repository.Owner.Login, _context.Repository.Name, "master");
// Assert the branch is unprotected, and enforcement/contexts are cleared
Assert.Equal(branch.Protection.Enabled, false);
Assert.Equal(branch.Protection.RequiredStatusChecks.EnforcementLevel, EnforcementLevel.Off);
Assert.Equal(branch.Protection.RequiredStatusChecks.Contexts.Count, 0);
}
}
}