mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-06 03:55:55 +00:00
Response objects need protected setters and ctors with parameters
Rework integration test examples
This commit is contained in:
committed by
Ryan Gribble
parent
894a6bceb2
commit
6b8312276f
@@ -42,11 +42,12 @@ public class BranchesClientTests
|
||||
public async Task CreateTheWorld()
|
||||
{
|
||||
// Set master branch to be protected, with some status checks
|
||||
var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Everyone, null);
|
||||
requiredStatusChecks.AddContext("check1");
|
||||
requiredStatusChecks.AddContext("check2");
|
||||
|
||||
var update = new BranchUpdate();
|
||||
update.Protection.Enabled = true;
|
||||
update.Protection.RequiredStatusChecks.EnforcementLevel = EnforcementLevel.Everyone;
|
||||
update.Protection.RequiredStatusChecks.AddContext("check1");
|
||||
update.Protection.RequiredStatusChecks.AddContext("check2");
|
||||
update.Protection = new BranchProtection(true, requiredStatusChecks);
|
||||
|
||||
var newBranch = await _fixture.EditBranch(_context.Repository.Owner.Login, _context.Repository.Name, "master", update);
|
||||
}
|
||||
@@ -55,12 +56,13 @@ public class BranchesClientTests
|
||||
public async Task ProtectsBranch()
|
||||
{
|
||||
// Set master branch to be protected, with some status checks
|
||||
var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Everyone, null);
|
||||
requiredStatusChecks.AddContext("check1");
|
||||
requiredStatusChecks.AddContext("check2");
|
||||
requiredStatusChecks.AddContext("check3");
|
||||
|
||||
var update = new BranchUpdate();
|
||||
update.Protection.Enabled = true;
|
||||
update.Protection.RequiredStatusChecks.EnforcementLevel = EnforcementLevel.Everyone;
|
||||
update.Protection.RequiredStatusChecks.AddContext("check1");
|
||||
update.Protection.RequiredStatusChecks.AddContext("check2");
|
||||
update.Protection.RequiredStatusChecks.AddContext("check3");
|
||||
update.Protection = new BranchProtection(true, requiredStatusChecks);
|
||||
|
||||
var branch = await _fixture.EditBranch(_context.Repository.Owner.Login, _context.Repository.Name, "master", update);
|
||||
|
||||
@@ -81,11 +83,13 @@ public class BranchesClientTests
|
||||
{
|
||||
await CreateTheWorld();
|
||||
|
||||
// Clear status checks
|
||||
// Remove status check enforcement
|
||||
var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Off, null);
|
||||
requiredStatusChecks.AddContext("check1");
|
||||
|
||||
var update = new BranchUpdate();
|
||||
update.Protection.Enabled = true;
|
||||
update.Protection.RequiredStatusChecks.EnforcementLevel = EnforcementLevel.Off;
|
||||
update.Protection.RequiredStatusChecks.AddContext("check1");
|
||||
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
|
||||
@@ -106,12 +110,13 @@ public class BranchesClientTests
|
||||
await CreateTheWorld();
|
||||
|
||||
// Unprotect branch
|
||||
var update = new BranchUpdate();
|
||||
update.Protection.Enabled = false;
|
||||
|
||||
// Deliberately set Enforcement and Contexts to some values (these should be ignored)
|
||||
update.Protection.RequiredStatusChecks.EnforcementLevel = EnforcementLevel.Everyone;
|
||||
update.Protection.RequiredStatusChecks.AddContext("check1");
|
||||
var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Everyone, null);
|
||||
requiredStatusChecks.AddContext("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
|
||||
|
||||
@@ -15,16 +15,17 @@ namespace Octokit
|
||||
/// <summary>
|
||||
/// Should this branch be protected or not
|
||||
/// </summary>
|
||||
public bool Enabled { get; set; }
|
||||
public bool Enabled { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="RequiredStatusChecks"/> information for this <see cref="Branch"/>.
|
||||
/// </summary>
|
||||
public RequiredStatusChecks RequiredStatusChecks { get; private set; }
|
||||
|
||||
public BranchProtection()
|
||||
public BranchProtection(bool enabled, RequiredStatusChecks requiredStatusChecks)
|
||||
{
|
||||
RequiredStatusChecks = new RequiredStatusChecks();
|
||||
Enabled = enabled;
|
||||
RequiredStatusChecks = requiredStatusChecks;
|
||||
}
|
||||
|
||||
internal string DebuggerDisplay
|
||||
@@ -42,13 +43,19 @@ namespace Octokit
|
||||
/// <summary>
|
||||
/// Who required status checks apply to
|
||||
/// </summary>
|
||||
public EnforcementLevel EnforcementLevel { get; set; }
|
||||
public EnforcementLevel EnforcementLevel { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// The list of status checks to require in order to merge into this <see cref="Branch"/>
|
||||
/// </summary>
|
||||
public ICollection<string> Contexts { get; private set; }
|
||||
|
||||
public RequiredStatusChecks(EnforcementLevel enforcementLevel, ICollection<string> contexts)
|
||||
{
|
||||
EnforcementLevel = enforcementLevel;
|
||||
Contexts = contexts;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified context to the required status checks.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user