From 5fe3ea82f03b7fe64bcf8145f3b127fa2c585665 Mon Sep 17 00:00:00 2001 From: Chris Simpson Date: Mon, 25 Jul 2022 16:36:09 +0100 Subject: [PATCH] tests: Updates and fixes for tests, changing master to main and adding flaky tests marker (#2511) --- .../Clients/BlobClientTests.cs | 2 +- .../CommitCommentReactionsClientTests.cs | 2 +- .../Clients/CommitStatusClientTests.cs | 2 +- .../Clients/CommitsClientTests.cs | 4 +- .../Clients/DeploymentStatusClientTests.cs | 2 +- .../Clients/DeploymentsClientTests.cs | 2 +- .../Clients/IssueCommentsClientTests.cs | 6 +- .../Clients/IssuesClientTests.cs | 4 +- .../Clients/MergingClientTests.cs | 24 +-- .../Clients/ProjectCardsClientTests.cs | 2 +- ...equestReviewCommentReactionsClientTests.cs | 62 +------ .../PullRequestReviewCommentsClientTests.cs | 16 +- .../PullRequestReviewRequestsClientTests.cs | 18 +- .../Clients/PullRequestReviewsClientTests.cs | 36 ++-- .../Clients/PullRequestsClientTests.cs | 156 ++++++++--------- .../Clients/ReferencesClientTests.cs | 14 +- .../Clients/ReleasesClientTests.cs | 16 +- .../Clients/RepositoriesClientTests.cs | 133 ++++++-------- .../Clients/RepositoryBranchesClientTests.cs | 162 +++++++++--------- .../Clients/RepositoryCommentsClientTests.cs | 12 +- .../Clients/RepositoryCommitsClientTests.cs | 40 ++--- .../Clients/RepositoryContentsClientTests.cs | 56 +++--- .../RepositoryDeployKeysClientTests.cs | 2 +- .../Clients/SearchClientTests.cs | 2 +- .../Clients/StatisticsClientTests.cs | 20 +-- .../Clients/TagsClientTests.cs | 4 +- .../Clients/TreeClientTests.cs | 6 +- .../Clients/WatchedClientTests.cs | 2 +- Octokit.Tests.Integration/Helper.cs | 2 + .../Helpers/GithubClientExtensions.cs | 97 +++++++++-- .../Helpers/PaidAccountTestAttribute.cs | 8 + .../Helpers/ReferenceExtensionsTests.cs | 6 +- .../Helpers/RepositorySetupHelper.cs | 16 +- .../PotentiallyFlakyTestAttribute.cs | 13 ++ .../ObservableCheckRunsClientTests.cs | 20 +-- .../ObservableCheckSuitesClientTests.cs | 16 +- 36 files changed, 494 insertions(+), 491 deletions(-) create mode 100644 Octokit.Tests.Integration/PotentiallyFlakyTestAttribute.cs diff --git a/Octokit.Tests.Integration/Clients/BlobClientTests.cs b/Octokit.Tests.Integration/Clients/BlobClientTests.cs index d0a3a9f8..8aeaf306 100644 --- a/Octokit.Tests.Integration/Clients/BlobClientTests.cs +++ b/Octokit.Tests.Integration/Clients/BlobClientTests.cs @@ -16,7 +16,7 @@ public class BlobClientTests : IDisposable var github = Helper.GetAuthenticatedClient(); _fixture = github.Git.Blob; - _context = github.CreateRepositoryContext("public-repo").Result; + _context = github.CreateRepositoryContextWithAutoInit("public-repo").Result; } [IntegrationTest] diff --git a/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs b/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs index 237e9988..fe008cec 100644 --- a/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs @@ -18,7 +18,7 @@ public class CommitCommentReactionsClientTests { _github = Helper.GetAuthenticatedClient(); - _context = _github.CreateRepositoryContext("public-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("public-repo").Result; } private async Task SetupCommitForRepository(IGitHubClient client) diff --git a/Octokit.Tests.Integration/Clients/CommitStatusClientTests.cs b/Octokit.Tests.Integration/Clients/CommitStatusClientTests.cs index 8f00b43f..3cccfd7f 100644 --- a/Octokit.Tests.Integration/Clients/CommitStatusClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CommitStatusClientTests.cs @@ -213,7 +213,7 @@ public class CommitStatusClientTests { _github = Helper.GetAuthenticatedClient(); - _context = _github.CreateRepositoryContext("public-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("public-repo").Result; } [IntegrationTest] diff --git a/Octokit.Tests.Integration/Clients/CommitsClientTests.cs b/Octokit.Tests.Integration/Clients/CommitsClientTests.cs index c2759a7f..16635536 100644 --- a/Octokit.Tests.Integration/Clients/CommitsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CommitsClientTests.cs @@ -12,7 +12,7 @@ public class CommitsClientTests var github = Helper.GetAuthenticatedClient(); var fixture = github.Git.Commit; - using (var context = await github.CreateRepositoryContext("public-repo")) + using (var context = await github.CreateRepositoryContextWithAutoInit("public-repo")) { var owner = context.Repository.Owner.Login; @@ -67,7 +67,7 @@ public class CommitsClientTests var github = Helper.GetAuthenticatedClient(); var fixture = github.Git.Commit; - using (var context = await github.CreateRepositoryContext("public-repo")) + using (var context = await github.CreateRepositoryContextWithAutoInit("public-repo")) { var owner = context.Repository.Owner.Login; diff --git a/Octokit.Tests.Integration/Clients/DeploymentStatusClientTests.cs b/Octokit.Tests.Integration/Clients/DeploymentStatusClientTests.cs index 3d19b48e..1fa4b899 100644 --- a/Octokit.Tests.Integration/Clients/DeploymentStatusClientTests.cs +++ b/Octokit.Tests.Integration/Clients/DeploymentStatusClientTests.cs @@ -16,7 +16,7 @@ public class DeploymentStatusClientTests : IDisposable var github = Helper.GetAuthenticatedClient(); _deploymentsClient = github.Repository.Deployment; - _context = github.CreateRepositoryContext("public-repo").Result; + _context = github.CreateRepositoryContextWithAutoInit("public-repo").Result; var blob = new NewBlob { diff --git a/Octokit.Tests.Integration/Clients/DeploymentsClientTests.cs b/Octokit.Tests.Integration/Clients/DeploymentsClientTests.cs index a0bc2d0d..43902fed 100644 --- a/Octokit.Tests.Integration/Clients/DeploymentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/DeploymentsClientTests.cs @@ -17,7 +17,7 @@ public class DeploymentsClientTests : IDisposable var github = Helper.GetAuthenticatedClient(); _deploymentsClient = github.Repository.Deployment; - _context = github.CreateRepositoryContext("public-repo").Result; + _context = github.CreateRepositoryContextWithAutoInit("public-repo").Result; var blob = new NewBlob { diff --git a/Octokit.Tests.Integration/Clients/IssueCommentsClientTests.cs b/Octokit.Tests.Integration/Clients/IssueCommentsClientTests.cs index 168b9c08..b9343e46 100644 --- a/Octokit.Tests.Integration/Clients/IssueCommentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssueCommentsClientTests.cs @@ -45,7 +45,7 @@ public class IssueCommentsClientTests [IntegrationTest] public async Task CanGetReactionPayload() { - using (var context = await _github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("IssueCommentsReactionTests"))) + using (var context = await _github.CreateRepositoryContextWithAutoInit(Helper.MakeNameWithTimestamp("IssueCommentsReactionTests"))) { // Create a test issue var issueNumber = await HelperCreateIssue(context.RepositoryOwner, context.RepositoryName); @@ -217,7 +217,7 @@ public class IssueCommentsClientTests public async Task CanGetReactionPayload() { var numberToCreate = 2; - using (var context = await _github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("IssueCommentsReactionTests"))) + using (var context = await _github.CreateRepositoryContextWithAutoInit(Helper.MakeNameWithTimestamp("IssueCommentsReactionTests"))) { var commentIds = new List(); @@ -402,7 +402,7 @@ public class IssueCommentsClientTests public async Task CanGetReactionPayload() { var numberToCreate = 2; - using (var context = await _github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("IssueCommentsReactionTests"))) + using (var context = await _github.CreateRepositoryContextWithAutoInit(Helper.MakeNameWithTimestamp("IssueCommentsReactionTests"))) { var commentIds = new List(); diff --git a/Octokit.Tests.Integration/Clients/IssuesClientTests.cs b/Octokit.Tests.Integration/Clients/IssuesClientTests.cs index 2d887ed0..88a793f2 100644 --- a/Octokit.Tests.Integration/Clients/IssuesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssuesClientTests.cs @@ -1288,7 +1288,7 @@ public class IssuesClientTests : IDisposable [IntegrationTest] public async Task CanGetReactionPayload() { - using (var context = await _github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("IssuesReactionTests"))) + using (var context = await _github.CreateRepositoryContextWithAutoInit(Helper.MakeNameWithTimestamp("IssuesReactionTests"))) { // Create a test issue with reactions var issueNumber = await HelperCreateIssue(context.RepositoryOwner, context.RepositoryName); @@ -1312,7 +1312,7 @@ public class IssuesClientTests : IDisposable public async Task CanGetReactionPayloadForMultipleIssues() { var numberToCreate = 2; - using (var context = await _github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("IssuesReactionTests"))) + using (var context = await _github.CreateRepositoryContextWithAutoInit(Helper.MakeNameWithTimestamp("IssuesReactionTests"))) { var issueNumbers = new List(); diff --git a/Octokit.Tests.Integration/Clients/MergingClientTests.cs b/Octokit.Tests.Integration/Clients/MergingClientTests.cs index dcbc5be9..66cc5578 100644 --- a/Octokit.Tests.Integration/Clients/MergingClientTests.cs +++ b/Octokit.Tests.Integration/Clients/MergingClientTests.cs @@ -22,7 +22,7 @@ public class MergingClientTests : IDisposable }; _fixture = _github.Repository.Merging; - _context = _github.CreateRepositoryContext("public-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("public-repo").Result; } [IntegrationTest] @@ -30,12 +30,12 @@ public class MergingClientTests : IDisposable { await CreateTheWorld(); - var newMerge = new NewMerge("master", branchName) { CommitMessage = "merge commit to master from integrationtests" }; + var newMerge = new NewMerge("main", branchName) { CommitMessage = "merge commit to main from integrationtests" }; var merge = await _fixture.Create(_context.RepositoryOwner, _context.RepositoryName, newMerge); Assert.NotNull(merge); Assert.NotNull(merge.Commit); - Assert.Equal("merge commit to master from integrationtests", merge.Commit.Message); + Assert.Equal("merge commit to main from integrationtests", merge.Commit.Message); } [IntegrationTest] @@ -43,28 +43,28 @@ public class MergingClientTests : IDisposable { await CreateTheWorld(); - var newMerge = new NewMerge("master", branchName) { CommitMessage = "merge commit to master from integrationtests" }; + var newMerge = new NewMerge("main", branchName) { CommitMessage = "merge commit to main from integrationtests" }; var merge = await _fixture.Create(_context.Repository.Id, newMerge); Assert.NotNull(merge); Assert.NotNull(merge.Commit); - Assert.Equal("merge commit to master from integrationtests", merge.Commit.Message); + Assert.Equal("merge commit to main from integrationtests", merge.Commit.Message); } async Task CreateTheWorld() { - var master = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/master"); + var main = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/main"); - // create new commit for master branch - var newMasterTree = await CreateTree(new Dictionary { { "README.md", "Hello World! I want to be overwritten by featurebranch!" } }); - var newMaster = await CreateCommit("baseline for merge", newMasterTree.Sha, master.Object.Sha); + // create new commit for main branch + var newMainTree = await CreateTree(new Dictionary { { "README.md", "Hello World! I want to be overwritten by featurebranch!" } }); + var newMain = await CreateCommit("baseline for merge", newMainTree.Sha, main.Object.Sha); - // update master - await _github.Git.Reference.Update(Helper.UserName, _context.RepositoryName, "heads/master", new ReferenceUpdate(newMaster.Sha)); + // update main + await _github.Git.Reference.Update(Helper.UserName, _context.RepositoryName, "heads/main", new ReferenceUpdate(newMain.Sha)); // create new commit for feature branch var featureBranchTree = await CreateTree(new Dictionary { { "README.md", "I am overwriting this blob with something new" } }); - var featureBranchCommit = await CreateCommit("this is the commit to merge", featureBranchTree.Sha, newMaster.Sha); + var featureBranchCommit = await CreateCommit("this is the commit to merge", featureBranchTree.Sha, newMain.Sha); // create branch await _github.Git.Reference.Create(Helper.UserName, _context.RepositoryName, new NewReference("refs/heads/my-branch", featureBranchCommit.Sha)); diff --git a/Octokit.Tests.Integration/Clients/ProjectCardsClientTests.cs b/Octokit.Tests.Integration/Clients/ProjectCardsClientTests.cs index c48cf675..97568ead 100644 --- a/Octokit.Tests.Integration/Clients/ProjectCardsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/ProjectCardsClientTests.cs @@ -203,7 +203,7 @@ public class ProjectCardsClientTests { _github = Helper.GetAuthenticatedClient(); - _context = _github.CreateRepositoryContext("public-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("public-repo").Result; } [IntegrationTest] diff --git a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs index 3e051184..a6a05c88 100644 --- a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs @@ -25,7 +25,7 @@ public class PullRequestReviewCommentReactionsClientTests : IDisposable _client = _github.PullRequest.ReviewComment; // We'll create a pull request that can be used by most tests - _context = _github.CreateRepositoryContext("test-repo").Result; + _context = _github.CreateUserRepositoryContext("test-repo").Result; } [IntegrationTest] @@ -339,60 +339,6 @@ public class PullRequestReviewCommentReactionsClientTests : IDisposable Assert.Equal(commentFromGitHub.User.Id, pullRequestReviewCommentReaction.User.Id); } - [IntegrationTest] - public async Task CanDeleteReaction() - { - var pullRequest = await CreatePullRequest(_context); - - const string body = "A review comment message"; - const int position = 1; - - var createdComment = await CreateComment(body, position, pullRequest.Sha, pullRequest.Number); - - var commentFromGitHub = await _client.GetComment(Helper.UserName, _context.RepositoryName, createdComment.Id); - - AssertComment(commentFromGitHub, body, position); - - foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) - { - var newReaction = new NewReaction(reactionType); - - var reaction = await _github.Reaction.PullRequestReviewComment.Create(_context.RepositoryOwner, _context.RepositoryName, commentFromGitHub.Id, newReaction); - await _github.Reaction.PullRequestReviewComment.Delete(_context.RepositoryOwner, _context.RepositoryName, commentFromGitHub.Id, reaction.Id); - } - - var allReactions = await _github.Reaction.PullRequestReviewComment.GetAll(_context.RepositoryOwner, _context.RepositoryName, commentFromGitHub.Id); - - Assert.Empty(allReactions); - } - - [IntegrationTest] - public async Task CanDeleteReactionWithRepositoryId() - { - var pullRequest = await CreatePullRequest(_context); - - const string body = "A review comment message"; - const int position = 1; - - var createdComment = await CreateComment(body, position, pullRequest.Sha, pullRequest.Number); - - var commentFromGitHub = await _client.GetComment(_context.RepositoryId, createdComment.Id); - - AssertComment(commentFromGitHub, body, position); - - foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) - { - var newReaction = new NewReaction(reactionType); - - var reaction = await _github.Reaction.PullRequestReviewComment.Create(_context.RepositoryId, commentFromGitHub.Id, newReaction); - await _github.Reaction.PullRequestReviewComment.Delete(_context.RepositoryId, commentFromGitHub.Id, reaction.Id); - } - - var allReactions = await _github.Reaction.PullRequestReviewComment.GetAll(_context.RepositoryId, commentFromGitHub.Id); - - Assert.Empty(allReactions); - } - /// /// Creates the base state for testing (creates a repo, a commit in master, a branch, a commit in the branch and a pull request) /// @@ -403,11 +349,11 @@ public class PullRequestReviewCommentReactionsClientTests : IDisposable // Creating a commit in master - var createdCommitInMaster = await CreateCommit(repoName, "Hello World!", "README.md", "heads/main", "A master commit message"); + var createdCommitInMain = await CreateCommit(repoName, "Hello World!", "README.md", "heads/main", "A main commit message"); // Creating a branch - var newBranch = new NewReference(branchRef, createdCommitInMaster.Sha); + var newBranch = new NewReference(branchRef, createdCommitInMain.Sha); await _github.Git.Reference.Create(Helper.UserName, repoName, newBranch); // Creating a commit in the branch @@ -416,7 +362,7 @@ public class PullRequestReviewCommentReactionsClientTests : IDisposable // Creating a pull request - var pullRequest = new NewPullRequest("Nice title for the pull request", branchName, "main"); + var pullRequest = new NewPullRequest("Nice title for the pull request", branchName, "master"); var createdPullRequest = await _github.PullRequest.Create(Helper.UserName, repoName, pullRequest); var data = new PullRequestData diff --git a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentsClientTests.cs b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentsClientTests.cs index ad51225d..82e2f9bb 100644 --- a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentsClientTests.cs @@ -23,7 +23,7 @@ public class PullRequestReviewCommentsClientTests : IDisposable _client = _github.PullRequest.ReviewComment; // We'll create a pull request that can be used by most tests - _context = _github.CreateRepositoryContext("test-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("test-repo").Result; } [IntegrationTest] @@ -844,7 +844,7 @@ public class PullRequestReviewCommentsClientTests : IDisposable } /// - /// Creates the base state for testing (creates a repo, a commit in master, a branch, a commit in the branch and a pull request) + /// Creates the base state for testing (creates a repo, a commit in main, a branch, a commit in the branch and a pull request) /// /// async Task CreatePullRequest(RepositoryContext context, string branch = branchName) @@ -855,13 +855,13 @@ public class PullRequestReviewCommentsClientTests : IDisposable var repoName = context.RepositoryName; - // Creating a commit in master + // Creating a commit in main - var createdCommitInMaster = await CreateCommit(repoName, "Hello World!", "README.md", "heads/master", "A master commit message"); + var createdCommitInMain = await CreateCommit(repoName, "Hello World!", "README.md", "heads/main", "A main commit message"); // Creating a branch - var newBranch = new NewReference(branchRef, createdCommitInMaster.Sha); + var newBranch = new NewReference(branchRef, createdCommitInMain.Sha); await _github.Git.Reference.Create(Helper.UserName, repoName, newBranch); // Creating a commit in the branch @@ -870,7 +870,7 @@ public class PullRequestReviewCommentsClientTests : IDisposable // Creating a pull request - var pullRequest = new NewPullRequest("Nice title for the pull request", branch, "master"); + var pullRequest = new NewPullRequest("Nice title for the pull request", branch, "main"); var createdPullRequest = await _github.PullRequest.Create(Helper.UserName, repoName, pullRequest); var data = new PullRequestData @@ -926,7 +926,7 @@ public class PullRequestReviewCommentsClientTests : IDisposable public async Task CanGetReactionPayloadForPullRequestReviews() { int numberToCreate = 2; - using (var context = await _github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("PullRequestReviewCommentsReactionTests"))) + using (var context = await _github.CreateRepositoryContextWithAutoInit(Helper.MakeNameWithTimestamp("PullRequestReviewCommentsReactionTests"))) { var commentIds = new List(); @@ -965,7 +965,7 @@ public class PullRequestReviewCommentsClientTests : IDisposable public async Task CanGetReactionPayloadForRepositoryPullRequestReviews() { int numberToCreate = 2; - using (var context = await _github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("PullRequestReviewCommentsReactionTests"))) + using (var context = await _github.CreateRepositoryContextWithAutoInit(Helper.MakeNameWithTimestamp("PullRequestReviewCommentsReactionTests"))) { var commentIds = new List(); diff --git a/Octokit.Tests.Integration/Clients/PullRequestReviewRequestsClientTests.cs b/Octokit.Tests.Integration/Clients/PullRequestReviewRequestsClientTests.cs index 4c20d2e9..c0ee6c0b 100644 --- a/Octokit.Tests.Integration/Clients/PullRequestReviewRequestsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/PullRequestReviewRequestsClientTests.cs @@ -26,7 +26,7 @@ public class PullRequestReviewRequestsClientTests _client = _github.PullRequest.ReviewRequest; - _context = _github.CreateRepositoryContext("test-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("test-repo").Result; Task.WaitAll(_collaboratorLogins.Select(AddCollaborator).ToArray()); } @@ -144,18 +144,18 @@ public class PullRequestReviewRequestsClientTests static async Task CreateTheWorld(IGitHubClient github, RepositoryContext context, bool createReviewRequests = true) { - var master = await github.Git.Reference.Get(context.RepositoryOwner, context.RepositoryName, "heads/master"); + var main = await github.Git.Reference.Get(context.RepositoryOwner, context.RepositoryName, "heads/main"); - // create new commit for master branch - var newMasterTree = await CreateTree(github, context, new Dictionary { { "README.md", "Hello World!" } }); - var newMaster = await CreateCommit(github, context, "baseline for pull request", newMasterTree.Sha, master.Object.Sha); + // create new commit for main branch + var newMainTree = await CreateTree(github, context, new Dictionary { { "README.md", "Hello World!" } }); + var newMain = await CreateCommit(github, context, "baseline for pull request", newMainTree.Sha, main.Object.Sha); - // update master - await github.Git.Reference.Update(context.RepositoryOwner, context.RepositoryName, "heads/master", new ReferenceUpdate(newMaster.Sha)); + // update main + await github.Git.Reference.Update(context.RepositoryOwner, context.RepositoryName, "heads/main", new ReferenceUpdate(newMain.Sha)); // create new commit for feature branch var featureBranchTree = await CreateTree(github, context, new Dictionary { { "README.md", "I am overwriting this blob with something new" } }); - var featureBranchCommit = await CreateCommit(github, context, "this is the commit to merge into the pull request", featureBranchTree.Sha, newMaster.Sha); + var featureBranchCommit = await CreateCommit(github, context, "this is the commit to merge into the pull request", featureBranchTree.Sha, newMain.Sha); var featureBranchTree2 = await CreateTree(github, context, new Dictionary { { "README.md", "I am overwriting this blob with something new a 2nd time" } }); var featureBranchCommit2 = await CreateCommit(github, context, "this is a 2nd commit to merge into the pull request", featureBranchTree2.Sha, featureBranchCommit.Sha); @@ -164,7 +164,7 @@ public class PullRequestReviewRequestsClientTests await github.Git.Reference.Create(context.RepositoryOwner, context.RepositoryName, new NewReference("refs/heads/my-branch", featureBranchCommit2.Sha)); // create a pull request - var pullRequest = new NewPullRequest("Nice title for the pull request", "my-branch", "master"); + var pullRequest = new NewPullRequest("Nice title for the pull request", "my-branch", "main"); var createdPullRequest = await github.PullRequest.Create(context.RepositoryOwner, context.RepositoryName, pullRequest); // Create review requests (optional) diff --git a/Octokit.Tests.Integration/Clients/PullRequestReviewsClientTests.cs b/Octokit.Tests.Integration/Clients/PullRequestReviewsClientTests.cs index 3b7d5217..5e57ca59 100644 --- a/Octokit.Tests.Integration/Clients/PullRequestReviewsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/PullRequestReviewsClientTests.cs @@ -126,7 +126,7 @@ public class PullRequestReviewsClientTests [DualAccountTest] public async Task CanCreatePendingReview() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -156,7 +156,7 @@ public class PullRequestReviewsClientTests [DualAccountTest] public async Task CanCreatePendingReviewWithRepositoryId() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -186,7 +186,7 @@ public class PullRequestReviewsClientTests [DualAccountTest] public async Task CanCreateCommentedReview() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -217,7 +217,7 @@ public class PullRequestReviewsClientTests [DualAccountTest] public async Task CanCreateCommentedReviewWithRepositoryId() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -248,7 +248,7 @@ public class PullRequestReviewsClientTests [DualAccountTest] public async Task CanCreateChangesRequestedReview() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -279,7 +279,7 @@ public class PullRequestReviewsClientTests [DualAccountTest] public async Task CanCreateChangesRequestedReviewWithRepositoryId() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -310,7 +310,7 @@ public class PullRequestReviewsClientTests [DualAccountTest] public async Task CanCreateApprovedReview() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -341,7 +341,7 @@ public class PullRequestReviewsClientTests [DualAccountTest] public async Task CanCreateApprovedReviewWithRepositoryId() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -388,7 +388,7 @@ public class PullRequestReviewsClientTests [DualAccountTest] public async Task CanDeleteReview() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -405,7 +405,7 @@ public class PullRequestReviewsClientTests [DualAccountTest] public async Task CanDeleteReviewWithRepositoryId() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -438,7 +438,7 @@ public class PullRequestReviewsClientTests [DualAccountTest] public async Task CanDismissReview() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -453,7 +453,7 @@ public class PullRequestReviewsClientTests [DualAccountTest] public async Task CanDismissReviewWithRepositoryId() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -565,7 +565,7 @@ public class PullRequestReviewsClientTests [DualAccountTest] public async Task CanSubmitCommentedReview() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -586,7 +586,7 @@ public class PullRequestReviewsClientTests [DualAccountTest] public async Task CanSubmitCommentedReviewWithRepositoryId() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -607,7 +607,7 @@ public class PullRequestReviewsClientTests [DualAccountTest] public async Task CanSubmitChangesRequestedReview() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -628,7 +628,7 @@ public class PullRequestReviewsClientTests [DualAccountTest] public async Task CanSubmitChangesRequestedReviewWithRepositoryId() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -649,7 +649,7 @@ public class PullRequestReviewsClientTests [DualAccountTest] public async Task CanSubmitApprovedReview() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -670,7 +670,7 @@ public class PullRequestReviewsClientTests [DualAccountTest] public async Task CanSubmitApprovedReviewWithRepositoryId() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); diff --git a/Octokit.Tests.Integration/Clients/PullRequestsClientTests.cs b/Octokit.Tests.Integration/Clients/PullRequestsClientTests.cs index 0b01c085..8985e28b 100644 --- a/Octokit.Tests.Integration/Clients/PullRequestsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/PullRequestsClientTests.cs @@ -25,7 +25,7 @@ public class PullRequestsClientTests : IDisposable _fixture = _github.Repository.PullRequest; _repositoryCommentsClient = _github.Repository.Comment; - _context = _github.CreateRepositoryContext("source-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("source-repo").Result; } [IntegrationTest] @@ -33,7 +33,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); Assert.Equal("a pull request", result.Title); } @@ -43,7 +43,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a draft pull request", branchName, "master") { Draft = true }; + var newPullRequest = new NewPullRequest("a draft pull request", branchName, "main") { Draft = true }; var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); Assert.Equal("a draft pull request", result.Title); Assert.True(result.Draft); @@ -55,7 +55,7 @@ public class PullRequestsClientTests : IDisposable await CreateTheWorld(); var newIssue = await _github.Issue.Create(Helper.UserName, _context.RepositoryName, new NewIssue("an issue")); - var newPullRequest = new NewPullRequest(newIssue.Number, branchName, "master"); + var newPullRequest = new NewPullRequest(newIssue.Number, branchName, "main"); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); Assert.Equal(newIssue.Number, result.Number); Assert.Equal(newIssue.Title, result.Title); @@ -66,7 +66,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var result = await _fixture.Create(_context.Repository.Id, newPullRequest); Assert.Equal("a pull request", result.Title); } @@ -76,7 +76,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a draft pull request", branchName, "master") { Draft = true }; + var newPullRequest = new NewPullRequest("a draft pull request", branchName, "main") { Draft = true }; var result = await _fixture.Create(_context.Repository.Id, newPullRequest); Assert.Equal("a draft pull request", result.Title); Assert.True(result.Draft); @@ -88,7 +88,7 @@ public class PullRequestsClientTests : IDisposable await CreateTheWorld(); var newIssue = await _github.Issue.Create(_context.RepositoryId, new NewIssue("an issue")); - var newPullRequest = new NewPullRequest(newIssue.Number, branchName, "master"); + var newPullRequest = new NewPullRequest(newIssue.Number, branchName, "main"); var result = await _fixture.Create(_context.Repository.Id, newPullRequest); Assert.Equal(newIssue.Number, result.Number); Assert.Equal(newIssue.Title, result.Title); @@ -99,7 +99,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var pullRequests = await _fixture.GetAllForRepository(Helper.UserName, _context.RepositoryName); @@ -114,7 +114,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a draft pull request", branchName, "master") { Draft = true }; + var newPullRequest = new NewPullRequest("a draft pull request", branchName, "main") { Draft = true }; var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var pullRequests = await _fixture.GetAllForRepository(Helper.UserName, _context.RepositoryName); @@ -130,7 +130,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var pullRequests = await _fixture.GetAllForRepository(_context.Repository.Id); @@ -144,7 +144,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a draft pull request", branchName, "master") { Draft = true }; + var newPullRequest = new NewPullRequest("a draft pull request", branchName, "main") { Draft = true }; var result = await _fixture.Create(_context.Repository.Id, newPullRequest); var pullRequests = await _fixture.GetAllForRepository(_context.Repository.Id); @@ -160,7 +160,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); // Add an assignee @@ -183,7 +183,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var result = await _fixture.Create(_context.Repository.Id, newPullRequest); // Add an assignee @@ -206,7 +206,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); // Add a label @@ -229,7 +229,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var result = await _fixture.Create(_context.Repository.Id, newPullRequest); // Add a label @@ -252,7 +252,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var options = new ApiOptions @@ -272,7 +272,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var options = new ApiOptions @@ -292,8 +292,8 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "master"); - var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "master"); + var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "main"); + var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "main"); await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest1); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest2); @@ -315,8 +315,8 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "master"); - var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "master"); + var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "main"); + var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "main"); await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest1); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest2); @@ -338,8 +338,8 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "master"); - var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "master"); + var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "main"); + var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "main"); await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest1); await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest2); @@ -368,8 +368,8 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "master"); - var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "master"); + var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "main"); + var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "main"); await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest1); await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest2); @@ -398,7 +398,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var openPullRequests = new PullRequestRequest { State = ItemStateFilter.Open }; @@ -413,7 +413,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var openPullRequests = new PullRequestRequest { State = ItemStateFilter.Open }; @@ -428,7 +428,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var options = new ApiOptions @@ -449,7 +449,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var options = new ApiOptions @@ -470,8 +470,8 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "master"); - var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "master"); + var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "main"); + var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "main"); await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest1); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest2); @@ -494,8 +494,8 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "master"); - var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "master"); + var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "main"); + var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "main"); await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest1); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest2); @@ -518,8 +518,8 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "master"); - var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "master"); + var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "main"); + var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "main"); await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest1); await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest2); @@ -550,8 +550,8 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "master"); - var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "master"); + var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "main"); + var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "main"); await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest1); await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest2); @@ -582,7 +582,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var openPullRequests = new PullRequestRequest { State = ItemStateFilter.Closed }; @@ -596,7 +596,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var openPullRequests = new PullRequestRequest { State = ItemStateFilter.Closed }; @@ -610,7 +610,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var updatePullRequest = new PullRequestUpdate { Title = "updated title", Body = "Hello New Body", Base = "my-other-branch" }; @@ -626,7 +626,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var updatePullRequest = new PullRequestUpdate { Title = "updated title", Body = "Hello New Body", Base = "my-other-branch" }; @@ -642,7 +642,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var updatePullRequest = new PullRequestUpdate { State = ItemState.Closed }; @@ -658,7 +658,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var updatePullRequest = new PullRequestUpdate { State = ItemState.Closed }; @@ -675,10 +675,10 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); - var newPullRequest2 = new NewPullRequest("another pull request", otherBranchName, "master"); + var newPullRequest2 = new NewPullRequest("another pull request", otherBranchName, "main"); var anotherPullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest2); var updatePullRequest = new PullRequestUpdate { Body = "This is the body" }; @@ -698,10 +698,10 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); - var newPullRequest2 = new NewPullRequest("another pull request", otherBranchName, "master"); + var newPullRequest2 = new NewPullRequest("another pull request", otherBranchName, "main"); var anotherPullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest2); var pullRequests = await _fixture.GetAllForRepository(Helper.UserName, _context.RepositoryName, new PullRequestRequest { SortDirection = SortDirection.Ascending }); @@ -716,7 +716,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var result = await _fixture.Merged(Helper.UserName, _context.RepositoryName, pullRequest.Number); @@ -729,7 +729,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var result = await _fixture.Merged(_context.Repository.Id, pullRequest.Number); @@ -742,7 +742,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var merge = new MergePullRequest { CommitMessage = "thing the thing" }; @@ -756,7 +756,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var merge = new MergePullRequest { CommitMessage = "thing the thing" }; @@ -770,7 +770,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var merge = new MergePullRequest(); @@ -784,7 +784,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var merge = new MergePullRequest { CommitMessage = "thing the thing", Sha = pullRequest.Head.Sha }; @@ -798,7 +798,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("squash commit pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("squash commit pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var merge = new MergePullRequest { CommitMessage = "fake commit message", CommitTitle = "fake title", MergeMethod = PullRequestMergeMethod.Merge }; @@ -814,7 +814,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("squash commit pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("squash commit pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var merge = new MergePullRequest { CommitMessage = "fake commit message", CommitTitle = "fake title", MergeMethod = PullRequestMergeMethod.Squash }; @@ -830,7 +830,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("squash commit pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("squash commit pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var merge = new MergePullRequest { CommitMessage = "fake commit message", CommitTitle = "fake title", MergeMethod = PullRequestMergeMethod.Rebase }; @@ -847,7 +847,7 @@ public class PullRequestsClientTests : IDisposable await CreateTheWorld(); var fakeSha = new string('f', 40); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var merge = new MergePullRequest { Sha = fakeSha }; @@ -861,12 +861,12 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var master = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/master"); - var newMasterTree = await CreateTree(new Dictionary { { "README.md", "Hello World, we meet again!" } }); - var masterCommit = await CreateCommit("Commit in master", newMasterTree.Sha, master.Object.Sha); - await _github.Git.Reference.Update(Helper.UserName, _context.RepositoryName, "heads/master", new ReferenceUpdate(masterCommit.Sha)); + var main = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/main"); + var newMainTree = await CreateTree(new Dictionary { { "README.md", "Hello World, we meet again!" } }); + var mainCommit = await CreateCommit("Commit in main", newMainTree.Sha, main.Object.Sha); + await _github.Git.Reference.Update(Helper.UserName, _context.RepositoryName, "heads/main", new ReferenceUpdate(mainCommit.Sha)); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); await Task.Delay(TimeSpan.FromSeconds(5)); @@ -883,19 +883,19 @@ public class PullRequestsClientTests : IDisposable } [IntegrationTest] - public async Task UpdatesMaster() + public async Task UpdatesMain() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var merge = new MergePullRequest { CommitMessage = "thing the thing" }; var result = await _fixture.Merge(Helper.UserName, _context.RepositoryName, pullRequest.Number, merge); - var master = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/master"); + var main = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/main"); - Assert.Equal(result.Sha, master.Object.Sha); + Assert.Equal(result.Sha, main.Object.Sha); } [IntegrationTest] @@ -903,7 +903,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var result = await _fixture.Commits(Helper.UserName, _context.RepositoryName, pullRequest.Number); @@ -917,7 +917,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var result = await _fixture.Commits(_context.Repository.Id, pullRequest.Number); @@ -931,7 +931,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); // create new commit for branch @@ -963,7 +963,7 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); // create new commit for branch @@ -1040,18 +1040,18 @@ public class PullRequestsClientTests : IDisposable async Task CreateTheWorld() { - var master = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/master"); + var main = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/main"); - // create new commit for master branch - var newMasterTree = await CreateTree(new Dictionary { { "README.md", "Hello World!" } }); - var newMaster = await CreateCommit("baseline for pull request", newMasterTree.Sha, master.Object.Sha); + // create new commit for main branch + var newMainTree = await CreateTree(new Dictionary { { "README.md", "Hello World!" } }); + var newMain = await CreateCommit("baseline for pull request", newMainTree.Sha, main.Object.Sha); - // update master - await _github.Git.Reference.Update(Helper.UserName, _context.RepositoryName, "heads/master", new ReferenceUpdate(newMaster.Sha)); + // update main + await _github.Git.Reference.Update(Helper.UserName, _context.RepositoryName, "heads/main", new ReferenceUpdate(newMain.Sha)); // create new commit for feature branch var featureBranchTree = await CreateTree(new Dictionary { { "README.md", "I am overwriting this blob with something new" } }); - var featureBranchCommit = await CreateCommit("this is the commit to merge into the pull request", featureBranchTree.Sha, newMaster.Sha); + var featureBranchCommit = await CreateCommit("this is the commit to merge into the pull request", featureBranchTree.Sha, newMain.Sha); var featureBranchTree2 = await CreateTree(new Dictionary { { "README.md", "I am overwriting this blob with something new a 2nd time" } }); var featureBranchCommit2 = await CreateCommit("this is a 2nd commit to merge into the pull request", featureBranchTree2.Sha, featureBranchCommit.Sha); @@ -1060,7 +1060,7 @@ public class PullRequestsClientTests : IDisposable await _github.Git.Reference.Create(Helper.UserName, _context.RepositoryName, new NewReference("refs/heads/my-branch", featureBranchCommit2.Sha)); var otherFeatureBranchTree = await CreateTree(new Dictionary { { "README.md", "I am overwriting this blob with something else" } }); - var otherFeatureBranchCommit = await CreateCommit("this is the other commit to merge into the other pull request", otherFeatureBranchTree.Sha, newMaster.Sha); + var otherFeatureBranchCommit = await CreateCommit("this is the other commit to merge into the other pull request", otherFeatureBranchTree.Sha, newMain.Sha); await _github.Git.Reference.Create(Helper.UserName, _context.RepositoryName, new NewReference("refs/heads/my-other-branch", otherFeatureBranchCommit.Sha)); } diff --git a/Octokit.Tests.Integration/Clients/ReferencesClientTests.cs b/Octokit.Tests.Integration/Clients/ReferencesClientTests.cs index 9f2c62bd..94f6157b 100644 --- a/Octokit.Tests.Integration/Clients/ReferencesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/ReferencesClientTests.cs @@ -18,17 +18,17 @@ public class ReferencesClientTests : IDisposable _fixture = _github.Git.Reference; - _context = _github.CreateRepositoryContext("public-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("public-repo").Result; } [IntegrationTest] public async Task CanGetAReference() { - var @ref = await _fixture.Get("octokit", "octokit.net", "heads/master"); + var @ref = await _fixture.Get("octokit", "octokit.net", "heads/main"); // validate the top-level properties - Assert.Equal("refs/heads/master", @ref.Ref); - Assert.Equal("https://api.github.com/repos/octokit/octokit.net/git/refs/heads/master", @ref.Url); + Assert.Equal("refs/heads/main", @ref.Ref); + Assert.Equal("https://api.github.com/repos/octokit/octokit.net/git/refs/heads/main", @ref.Url); // validate the git reference Assert.Equal(TaggedType.Commit, @ref.Object.Type); @@ -38,11 +38,11 @@ public class ReferencesClientTests : IDisposable [IntegrationTest] public async Task CanGetAReferenceWithRepositoryId() { - var @ref = await _fixture.Get(7528679, "heads/master"); + var @ref = await _fixture.Get(7528679, "heads/main"); // validate the top-level properties - Assert.Equal("refs/heads/master", @ref.Ref); - Assert.Equal("https://api.github.com/repos/octokit/octokit.net/git/refs/heads/master", @ref.Url); + Assert.Equal("refs/heads/main", @ref.Ref); + Assert.Equal("https://api.github.com/repos/octokit/octokit.net/git/refs/heads/main", @ref.Url); // validate the git reference Assert.Equal(TaggedType.Commit, @ref.Object.Type); diff --git a/Octokit.Tests.Integration/Clients/ReleasesClientTests.cs b/Octokit.Tests.Integration/Clients/ReleasesClientTests.cs index 58e3f608..258ec656 100644 --- a/Octokit.Tests.Integration/Clients/ReleasesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/ReleasesClientTests.cs @@ -32,7 +32,7 @@ public class ReleasesClientTests var github = Helper.GetAuthenticatedClient(); _releaseClient = github.Repository.Release; - _context = github.CreateRepositoryContext("public-repo").Result; + _context = github.CreateRepositoryContextWithAutoInit("public-repo").Result; } [IntegrationTest] @@ -71,7 +71,7 @@ public class ReleasesClientTests var github = Helper.GetAuthenticatedClient(); _releaseClient = github.Repository.Release; - _context = github.CreateRepositoryContext("public-repo").Result; + _context = github.CreateRepositoryContextWithAutoInit("public-repo").Result; } [IntegrationTest] @@ -365,7 +365,7 @@ public class ReleasesClientTests _github = Helper.GetAuthenticatedClient(); _releaseClient = _github.Repository.Release; - _context = _github.CreateRepositoryContext("public-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("public-repo").Result; } [IntegrationTest] @@ -408,7 +408,7 @@ public class ReleasesClientTests var releaseWithNoUpdate = new NewRelease("0.1") { Draft = true }; var release = await _releaseClient.Create(_context.RepositoryOwner, _context.RepositoryName, releaseWithNoUpdate); - Assert.Equal("master", release.TargetCommitish); + Assert.Equal("main", release.TargetCommitish); var newHead = await _github.CreateTheWorld(_context.Repository); @@ -429,7 +429,7 @@ public class ReleasesClientTests var releaseWithNoUpdate = new NewRelease("0.1") { Draft = true }; var release = await _releaseClient.Create(_context.Repository.Id, releaseWithNoUpdate); - Assert.Equal("master", release.TargetCommitish); + Assert.Equal("main", release.TargetCommitish); var newHead = await _github.CreateTheWorld(_context.Repository); @@ -465,7 +465,7 @@ public class ReleasesClientTests _github = Helper.GetAuthenticatedClient(); _releaseClient = _github.Repository.Release; - _context = _github.CreateRepositoryContext("public-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("public-repo").Result; } [IntegrationTest] @@ -812,7 +812,7 @@ public class ReleasesClientTests _github = Helper.GetAuthenticatedClient(); _releaseClient = _github.Repository.Release; - _context = _github.CreateRepositoryContext("public-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("public-repo").Result; } [IntegrationTest] @@ -867,7 +867,7 @@ public class ReleasesClientTests _github = Helper.GetAuthenticatedClient(); _releaseClient = _github.Repository.Release; - _context = _github.CreateRepositoryContext("public-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("public-repo").Result; } [IntegrationTest] diff --git a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs index 00938852..ce2a9fa3 100644 --- a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs @@ -511,7 +511,7 @@ public class RepositoriesClientTests [IntegrationTest] public async Task UpdatesNothing() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate(); @@ -542,7 +542,7 @@ public class RepositoriesClientTests [IntegrationTest] public async Task UpdatesName() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var updatedName = Helper.MakeNameWithTimestamp("updated-repo"); var update = new RepositoryUpdate() { Name = updatedName }; @@ -556,7 +556,7 @@ public class RepositoriesClientTests [IntegrationTest] public async Task UpdatesNameWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var updatedName = Helper.MakeNameWithTimestamp("updated-repo"); var update = new RepositoryUpdate() { Name = updatedName }; @@ -570,7 +570,7 @@ public class RepositoriesClientTests [IntegrationTest] public async Task UpdatesNameObsolete() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var updatedName = Helper.MakeNameWithTimestamp("updated-repo"); var update = new RepositoryUpdate(updatedName); @@ -584,7 +584,7 @@ public class RepositoriesClientTests [IntegrationTest] public async Task UpdatesNameWithRepositoryIdObsolete() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var updatedName = Helper.MakeNameWithTimestamp("updated-repo"); var update = new RepositoryUpdate(updatedName); @@ -598,7 +598,7 @@ public class RepositoriesClientTests [IntegrationTest] public async Task UpdatesDescription() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { Description = "Updated description" }; @@ -611,7 +611,7 @@ public class RepositoriesClientTests [IntegrationTest] public async Task UpdatesDescriptionWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { Description = "Updated description" }; @@ -624,7 +624,7 @@ public class RepositoriesClientTests [IntegrationTest] public async Task UpdatesHomepage() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { Homepage = "http://aUrl.to/nowhere" }; @@ -637,7 +637,7 @@ public class RepositoriesClientTests [IntegrationTest] public async Task UpdatesHomepageWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { Homepage = "http://aUrl.to/nowhere" }; @@ -650,7 +650,7 @@ public class RepositoriesClientTests [PaidAccountTest] public async Task UpdatesPrivate() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { Private = true }; @@ -663,7 +663,7 @@ public class RepositoriesClientTests [PaidAccountTest] public async Task UpdatesPrivateWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { Private = true }; @@ -676,7 +676,7 @@ public class RepositoriesClientTests [IntegrationTest] public async Task UpdatesHasIssues() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { HasIssues = false }; @@ -689,7 +689,7 @@ public class RepositoriesClientTests [IntegrationTest] public async Task UpdatesHasIssuesWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { HasIssues = false }; @@ -702,7 +702,7 @@ public class RepositoriesClientTests [IntegrationTest] public async Task UpdatesHasWiki() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { HasWiki = false }; @@ -715,7 +715,7 @@ public class RepositoriesClientTests [IntegrationTest] public async Task UpdatesHasWikiWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { HasWiki = false }; @@ -728,7 +728,7 @@ public class RepositoriesClientTests [IntegrationTest] public async Task UpdatesHasDownloads() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { HasDownloads = false }; @@ -741,7 +741,7 @@ public class RepositoriesClientTests [IntegrationTest] public async Task UpdatesHasDownloadsWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { HasDownloads = false }; @@ -754,7 +754,7 @@ public class RepositoriesClientTests [IntegrationTest] public async Task UpdatesIsTemplate() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { IsTemplate = true }; @@ -767,7 +767,7 @@ public class RepositoriesClientTests [IntegrationTest] public async Task UpdatesIsTemplateWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { IsTemplate = true }; @@ -780,7 +780,7 @@ public class RepositoriesClientTests [IntegrationTest] public async Task UpdatesDefaultBranch() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var reference = _github.Git.Reference.GetAll(repoContext.RepositoryOwner, repoContext.RepositoryName).Result.First(); _github.Git.Reference.Create(repoContext.RepositoryId, new NewReference("refs/heads/primary", reference.Object.Sha)).Wait(); @@ -795,7 +795,7 @@ public class RepositoriesClientTests [IntegrationTest] public async Task UpdatesDefaultBranchWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var reference = _github.Git.Reference.GetAll(repoContext.RepositoryOwner, repoContext.RepositoryName).Result.First(); _github.Git.Reference.Create(repoContext.RepositoryId, new NewReference("refs/heads/primary", reference.Object.Sha)).Wait(); @@ -810,9 +810,8 @@ public class RepositoriesClientTests [IntegrationTest] public async Task UpdatesMergeMethod() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { - var updateRepository = new RepositoryUpdate() { AllowMergeCommit = false, @@ -832,7 +831,7 @@ public class RepositoriesClientTests [IntegrationTest] public async Task UpdatesMergeMethodWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var updateRepository = new RepositoryUpdate() { @@ -849,23 +848,26 @@ public class RepositoriesClientTests Assert.True(editedRepository.AllowAutoMerge); } } - + [IntegrationTest] public async Task UpdatesDeleteBranchOnMergeMethod() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var updateRepository = new RepositoryUpdate() { DeleteBranchOnMerge = true }; var editedRepository = await _github.Repository.Edit(repoContext.RepositoryOwner, repoContext.RepositoryName, updateRepository); Assert.True(editedRepository.DeleteBranchOnMerge); + + var repository = await _github.Repository.Get(repoContext.RepositoryOwner, repoContext.RepositoryName); + Assert.True(repository.DeleteBranchOnMerge); } } - + [IntegrationTest] public async Task UpdatesDeleteBranchOnMergeMethodWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var updateRepository = new RepositoryUpdate() { DeleteBranchOnMerge = true }; @@ -877,7 +879,7 @@ public class RepositoriesClientTests [IntegrationTest] public async Task UpdatesArchive() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { Archived = true }; @@ -890,7 +892,7 @@ public class RepositoriesClientTests [IntegrationTest] public async Task UpdatesArchiveWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { Archived = true }; @@ -928,9 +930,10 @@ public class RepositoriesClientTests } } - public class TheGetMethod + public class TheGetMethod : GitHubClientTestBase { [IntegrationTest] + [PotentiallyFlakyTest] public async Task ReturnsSpecifiedRepository() { var github = Helper.GetAuthenticatedClient(); @@ -945,6 +948,7 @@ public class RepositoriesClientTests } [IntegrationTest] + [PotentiallyFlakyTest] public async Task ReturnsSpecifiedRepositoryWithRepositoryId() { var github = Helper.GetAuthenticatedClient(); @@ -959,6 +963,7 @@ public class RepositoriesClientTests } [IntegrationTest] + [PotentiallyFlakyTest] public async Task ReturnsOrganizationRepository() { var github = Helper.GetAuthenticatedClient(); @@ -972,6 +977,7 @@ public class RepositoriesClientTests } [IntegrationTest] + [PotentiallyFlakyTest] public async Task ReturnsRenamedRepository() { var github = Helper.GetAuthenticatedClient(); @@ -997,6 +1003,7 @@ public class RepositoriesClientTests } [IntegrationTest] + [PotentiallyFlakyTest] public async Task ReturnsOrganizationRepositoryWithRepositoryId() { var github = Helper.GetAuthenticatedClient(); @@ -1010,6 +1017,7 @@ public class RepositoriesClientTests } [IntegrationTest] + [PotentiallyFlakyTest] public async Task ReturnsForkedRepository() { var github = Helper.GetAuthenticatedClient(); @@ -1021,6 +1029,7 @@ public class RepositoriesClientTests } [IntegrationTest] + [PotentiallyFlakyTest] public async Task ReturnsForkedRepositoryWithRepositoryId() { var github = Helper.GetAuthenticatedClient(); @@ -1036,7 +1045,7 @@ public class RepositoriesClientTests { var github = Helper.GetAuthenticatedClient(); - using (var context = await github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("public-repo"))) + using (var context = await github.CreateUserRepositoryContext(Helper.MakeNameWithTimestamp("public-repo"))) { var repository = await github.Repository.Get(context.RepositoryOwner, context.RepositoryName); @@ -1052,7 +1061,7 @@ public class RepositoriesClientTests { var github = Helper.GetAuthenticatedClient(); - using (var context = await github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("public-repo"))) + using (var context = await github.CreateUserRepositoryContext(Helper.MakeNameWithTimestamp("public-repo"))) { var repository = await github.Repository.Get(context.RepositoryId); @@ -1064,6 +1073,7 @@ public class RepositoriesClientTests } [IntegrationTest] + [PotentiallyFlakyTest] public async Task ReturnsSpecifiedRepositoryWithLicenseInformation() { var github = Helper.GetAuthenticatedClient(); @@ -1074,13 +1084,13 @@ public class RepositoriesClientTests Assert.Equal("mit", repository.License.Key); Assert.Equal("MIT License", repository.License.Name); } - + [IntegrationTest] public async Task ReturnsRepositoryDeleteBranchOnMergeOptions() { var github = Helper.GetAuthenticatedClient(); - using (var context = await github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("public-repo"))) + using (var context = await github.CreateUserRepositoryContext(Helper.MakeNameWithTimestamp("public-repo"))) { var repository = await github.Repository.Get(context.RepositoryOwner, context.RepositoryName); @@ -1093,7 +1103,7 @@ public class RepositoriesClientTests { var github = Helper.GetAuthenticatedClient(); - using (var context = await github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("public-repo"))) + using (var context = await github.CreateUserRepositoryContext(Helper.MakeNameWithTimestamp("public-repo"))) { var repository = await github.Repository.Get(context.RepositoryId); @@ -1632,7 +1642,7 @@ public class RepositoriesClientTests } } - public class TheGetAllLanguagesMethod + public class TheGetAllLanguagesMethod : GitHubClientTestBase { [IntegrationTest] public async Task GetsLanguages() @@ -1660,7 +1670,7 @@ public class RepositoriesClientTests public async Task GetsEmptyLanguagesWhenNone() { var github = Helper.GetAuthenticatedClient(); - using (var context = await github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("public-repo"))) + using (var context = await github.CreateUserRepositoryContext(Helper.MakeNameWithTimestamp("public-repo"))) { var languages = await github.Repository.GetAllLanguages(context.RepositoryOwner, context.RepositoryName); @@ -1672,7 +1682,7 @@ public class RepositoriesClientTests public async Task GetsEmptyLanguagesWhenNoneWithRepositoryId() { var github = Helper.GetAuthenticatedClient(); - using (var context = await github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("public-repo"))) + using (var context = await github.CreateUserRepositoryContext(Helper.MakeNameWithTimestamp("public-repo"))) { var languages = await github.Repository.GetAllLanguages(context.RepositoryId); @@ -2250,49 +2260,4 @@ public class RepositoriesClientTests Assert.True(enabled); } } - - public class RepositoryTestBaseClass : IDisposable - { - protected IGitHubClient _github; - - private readonly List _repositories; - - protected RepositoryTestBaseClass() - { - _github = Helper.GetAuthenticatedClient(); - _repositories = new List(); - } - - public void Dispose() - { - foreach (var repository in _repositories) - { - repository.Dispose(); - } - } - - /// - /// Returns a RepositoryContext, which will be disposed at the end of the test. - /// - /// Your value or uses default of Helper.MakeNameWithTimestamp("public-repo"); - /// - internal RepositoryContext CreateRepository(string name = null) - { - var newContext = _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp(name ?? Helper.MakeNameWithTimestamp("public-repo"))) { AutoInit = true }).Result; - _repositories.Add(newContext); - return newContext; - } - - /// - /// Returns a RepositoryContext, which will be disposed at the end of the test. - /// - /// Your value or uses default of Helper.MakeNameWithTimestamp("public-repo"); - /// - internal async Task CreateRepositoryAsync(string name = null) - { - var newContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp(name ?? Helper.MakeNameWithTimestamp("public-repo"))) { AutoInit = true }); - _repositories.Add(newContext); - return newContext; - } - } } diff --git a/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs index 9632171b..f2798554 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs @@ -14,7 +14,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task GetsAllBranches() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-1", repoContext.Repository.DefaultBranch); await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-2", repoContext.Repository.DefaultBranch); @@ -29,7 +29,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task GetsAllBranchesWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-1", repoContext.Repository.DefaultBranch); await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-2", repoContext.Repository.DefaultBranch); @@ -44,7 +44,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task ReturnsCorrectCountOfBranchesWithoutStart() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-1", repoContext.Repository.DefaultBranch); await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-2", repoContext.Repository.DefaultBranch); @@ -71,7 +71,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task ReturnsCorrectCountOfBranchesWithoutStartWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-1", repoContext.Repository.DefaultBranch); await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-2", repoContext.Repository.DefaultBranch); @@ -98,7 +98,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task ReturnsCorrectCountOfBranchesWithStart() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-1", repoContext.Repository.DefaultBranch); await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-2", repoContext.Repository.DefaultBranch); @@ -126,7 +126,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task ReturnsCorrectCountOfBranchesWithStartWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-1", repoContext.Repository.DefaultBranch); await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-2", repoContext.Repository.DefaultBranch); @@ -154,7 +154,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task GetsPagesOfBranches() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-1", repoContext.Repository.DefaultBranch); await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-2", repoContext.Repository.DefaultBranch); @@ -198,7 +198,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task GetsPagesOfBranchesWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-1", repoContext.Repository.DefaultBranch); await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-2", repoContext.Repository.DefaultBranch); @@ -245,7 +245,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task GetsABranch() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -261,7 +261,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task GetsABranchWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -280,7 +280,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task GetsBranchProtection() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -307,7 +307,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task GetsBranchProtectionWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -334,7 +334,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task GetsBranchProtectionForOrgRepo() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -358,7 +358,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task GetsBranchProtectionForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -385,7 +385,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task UpdatesBranchProtection() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -413,7 +413,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task UpdatesBranchProtectionWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -441,7 +441,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task UpdatesBranchProtectionForOrgRepo() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -471,7 +471,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task UpdatesBranchProtectionForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); var update = new BranchProtectionSettingsUpdate( @@ -503,7 +503,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task DeletesBranchProtection() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -516,7 +516,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task DeletesBranchProtectionWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -529,7 +529,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task DeletesBranchProtectionForOrgRepo() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -542,7 +542,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task DeletesBranchProtectionForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -558,7 +558,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task GetsRequiredStatusChecks() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); var requiredStatusChecks = await _github.Repository.Branch.GetRequiredStatusChecks(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch); @@ -573,7 +573,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task GetsRequiredStatusChecksWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); var requiredStatusChecks = await _github.Repository.Branch.GetRequiredStatusChecks(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); @@ -591,7 +591,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task UpdateRequiredStatusChecks() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -609,7 +609,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task UpdatesRequiredStatusChecksWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -630,7 +630,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task DeletesRequiredStatusChecks() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -643,7 +643,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task DeletesRequiredStatusChecksWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -659,7 +659,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task GetsRequiredStatusChecksContexts() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -673,7 +673,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task GetsRequiredStatusChecksContextsWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -690,7 +690,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task UpdateRequiredStatusChecksContexts() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -704,7 +704,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task UpdatesRequiredStatusChecksContextsWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -721,7 +721,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task AddsRequiredStatusChecksContexts() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -736,7 +736,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task AddsRequiredStatusChecksContextsWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -754,7 +754,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task DeletesRequiredStatusChecksContexts() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -769,7 +769,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task DeletesRequiredStatusChecksContextsWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -787,7 +787,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task GetsReviewEnforcement() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -802,7 +802,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task GetsReviewEnforcementWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -817,7 +817,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task GetsReviewEnforcementForOrgRepo() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -833,7 +833,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task GetsReviewEnforcementForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -852,7 +852,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task UpdatesReviewEnforcement() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -870,7 +870,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task UpdatesReviewEnforcementWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -888,7 +888,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task UpdatesReviewEnforcementForOrgRepo() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -910,7 +910,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task UpdatesReviewEnforcementForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -932,7 +932,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task UpdatesReviewEnforcementForOrgRepoWithAdminOnly() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -955,7 +955,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task UpdatesReviewEnforcementForOrgRepoWithAdminOnlyWithRepositoryId() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -981,7 +981,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task RemovesReviewEnforcement() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -994,7 +994,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task RemovesReviewEnforcementWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -1007,7 +1007,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task RemovesReviewEnforcementForOrgRepo() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1020,7 +1020,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task RemovesReviewEnforcementForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1036,7 +1036,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task GetsAdminEnforcement() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -1050,7 +1050,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task GetsAdminEnforcementWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -1067,7 +1067,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task AddsAdminEnforcement() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -1082,7 +1082,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task AddsAdminEnforcementoWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -1100,7 +1100,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task RemovesAdminEnforcement() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -1118,7 +1118,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task RemovesAdminEnforcementWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -1137,11 +1137,11 @@ namespace Octokit.Tests.Integration.Clients public class TheGetProtectedBranchRestrictionsMethod : GitHubClientTestBase { [OrganizationTest] - public async Task GetsRequirProtectedBranchRestrictionsForOrgRepo() + public async Task GetsProtectedBranchRestrictionsForOrgRepo() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { - await _github.ProtectDefaultBranch(repoContext); + await _github.ProtectDefaultBranchWithTeam(repoContext); var restrictions = await _github.Repository.Branch.GetProtectedBranchRestrictions(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch); @@ -1153,9 +1153,9 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task GetsProtectedBranchRestrictionsForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { - await _github.ProtectDefaultBranch(repoContext); + await _github.ProtectDefaultBranchWithTeam(repoContext); var restrictions = await _github.Repository.Branch.GetProtectedBranchRestrictions(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); @@ -1170,9 +1170,9 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task DeletesRProtectedBranchRestrictionsForOrgRepo() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { - await _github.ProtectDefaultBranch(repoContext); + await _github.ProtectDefaultBranchWithTeam(repoContext); var deleted = await _github.Repository.Branch.DeleteProtectedBranchRestrictions(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch); @@ -1183,9 +1183,9 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task DeletesProtectedBranchRestrictionsForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { - await _github.ProtectDefaultBranch(repoContext); + await _github.ProtectDefaultBranchWithTeam(repoContext); var deleted = await _github.Repository.Branch.DeleteProtectedBranchRestrictions(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); @@ -1199,7 +1199,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task GetsProtectedBranchTeamRestrictionsForOrgRepo() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1213,7 +1213,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task GetsProtectedBranchTeamRestrictionsForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1230,7 +1230,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task UpdatesProtectedBranchTeamRestrictionsForOrgRepo() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1254,7 +1254,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task UpdatesProtectedBranchTeamRestrictionsForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1281,7 +1281,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task AddsProtectedBranchTeamRestrictionsForOrgRepo() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1305,7 +1305,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task AddsProtectedBranchTeamRestrictionsForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1332,7 +1332,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task DeletesRProtectedBranchTeamRestrictionsForOrgRepo() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { var team = await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1347,7 +1347,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task DeletesProtectedBranchTeamRestrictionsForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { var team = await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1365,7 +1365,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task GetsProtectedBranchUserRestrictionsForOrgRepo() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1379,7 +1379,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task GetsProtectedBranchUserRestrictionsForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1396,7 +1396,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task UpdatesProtectedBranchUserRestrictionsForOrgRepo() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1412,7 +1412,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task UpdatesProtectedBranchUserRestrictionsForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1431,7 +1431,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task AddsProtectedBranchUserRestrictionsForOrgRepo() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { var team = await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1447,7 +1447,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task AddsProtectedBranchUserRestrictionsForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1466,7 +1466,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task DeletesProtectedBranchUserRestrictionsForOrgRepo() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1486,7 +1486,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task DeletesProtectedBranchUserRestrictionsForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); diff --git a/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs index aaccd9df..0cc715e9 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs @@ -41,7 +41,7 @@ public class RepositoryCommentsClientTests [IntegrationTest] public async Task CanGetReactionPayload() { - using (var context = await _github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("CommitCommentsReactionTests"))) + using (var context = await _github.CreateRepositoryContextWithAutoInit(Helper.MakeNameWithTimestamp("CommitCommentsReactionTests"))) { // Create a test commit var commit = await HelperCreateCommit(context.RepositoryOwner, context.RepositoryName); @@ -204,7 +204,7 @@ public class RepositoryCommentsClientTests public async Task CanGetReactionPayload() { var numberToCreate = 2; - using (var context = await _github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("CommitCommentsReactionTests"))) + using (var context = await _github.CreateRepositoryContextWithAutoInit(Helper.MakeNameWithTimestamp("CommitCommentsReactionTests"))) { var commentIds = new List(); @@ -379,7 +379,7 @@ public class RepositoryCommentsClientTests public async Task CanGetReactionPayload() { var numberToCreate = 2; - using (var context = await _github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("CommitCommentsReactionTests"))) + using (var context = await _github.CreateRepositoryContextWithAutoInit(Helper.MakeNameWithTimestamp("CommitCommentsReactionTests"))) { var commentIds = new List(); @@ -423,7 +423,7 @@ public class RepositoryCommentsClientTests public TheCreateMethod() { _github = Helper.GetAuthenticatedClient(); - _context = _github.CreateRepositoryContext("public-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("public-repo").Result; } private async Task SetupCommitForRepository(IGitHubClient client) @@ -532,7 +532,7 @@ public class RepositoryCommentsClientTests { _github = Helper.GetAuthenticatedClient(); - _context = _github.CreateRepositoryContext("public-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("public-repo").Result; } private async Task SetupCommitForRepository(IGitHubClient client) @@ -621,7 +621,7 @@ public class RepositoryCommentsClientTests { _github = Helper.GetAuthenticatedClient(); - _context = _github.CreateRepositoryContext("public-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("public-repo").Result; } private async Task SetupCommitForRepository(IGitHubClient client) diff --git a/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs index 3332d56d..e1d769f8 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs @@ -285,7 +285,7 @@ public class RepositoryCommitsClientTests [IntegrationTest] public async Task CanGetSha1() { - var sha1 = await _fixture.GetSha1(octokitNetRepositoryOwner, octokitNetRepositorName, "master"); + var sha1 = await _fixture.GetSha1(octokitNetRepositoryOwner, octokitNetRepositorName, "main"); Assert.NotNull(sha1); } @@ -293,7 +293,7 @@ public class RepositoryCommitsClientTests [IntegrationTest] public async Task CanGetSha1WithRepositoryId() { - var sha1 = await _fixture.GetSha1(octokitNetRepositoryId, "master"); + var sha1 = await _fixture.GetSha1(octokitNetRepositoryId, "main"); Assert.NotNull(sha1); } @@ -311,7 +311,7 @@ public class RepositoryCommitsClientTests _fixture = _github.Repository.Commit; - _context = _github.CreateRepositoryContext("source-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("source-repo").Result; } [IntegrationTest] @@ -319,7 +319,7 @@ public class RepositoryCommitsClientTests { await CreateTheWorld(); - var result = await _fixture.Compare(Helper.UserName, _context.RepositoryName, "master", "my-branch"); + var result = await _fixture.Compare(Helper.UserName, _context.RepositoryName, "main", "my-branch"); Assert.Equal(1, result.TotalCommits); Assert.Equal(1, result.Commits.Count); @@ -332,7 +332,7 @@ public class RepositoryCommitsClientTests { await CreateTheWorld(); - var result = await _fixture.Compare(_context.Repository.Id, "master", "my-branch"); + var result = await _fixture.Compare(_context.Repository.Id, "main", "my-branch"); Assert.Equal(1, result.TotalCommits); Assert.Equal(1, result.Commits.Count); @@ -345,7 +345,7 @@ public class RepositoryCommitsClientTests { await CreateTheWorld(); - var result = await _fixture.Compare(Helper.UserName, _context.RepositoryName, "my-branch", "master"); + var result = await _fixture.Compare(Helper.UserName, _context.RepositoryName, "my-branch", "main"); Assert.Equal(0, result.TotalCommits); Assert.Equal(0, result.Commits.Count); @@ -358,7 +358,7 @@ public class RepositoryCommitsClientTests { await CreateTheWorld(); - var result = await _fixture.Compare(_context.Repository.Id, "my-branch", "master"); + var result = await _fixture.Compare(_context.Repository.Id, "my-branch", "main"); Assert.Equal(0, result.TotalCommits); Assert.Equal(0, result.Commits.Count); @@ -371,7 +371,7 @@ public class RepositoryCommitsClientTests { await CreateTheWorld(); - var result = await _fixture.Compare(Helper.UserName, _context.RepositoryName, "my-branch", "master"); + var result = await _fixture.Compare(Helper.UserName, _context.RepositoryName, "my-branch", "main"); Assert.NotNull(result.DiffUrl); Assert.NotNull(result.HtmlUrl); @@ -384,7 +384,7 @@ public class RepositoryCommitsClientTests { await CreateTheWorld(); - var result = await _fixture.Compare(_context.Repository.Id, "my-branch", "master"); + var result = await _fixture.Compare(_context.Repository.Id, "my-branch", "main"); Assert.NotNull(result.DiffUrl); Assert.NotNull(result.HtmlUrl); @@ -397,10 +397,10 @@ public class RepositoryCommitsClientTests { await CreateTheWorld(); - var master = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/master"); + var main = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/main"); var branch = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/my-branch"); - var result = await _fixture.Compare(Helper.UserName, _context.RepositoryName, master.Object.Sha, branch.Object.Sha); + var result = await _fixture.Compare(Helper.UserName, _context.RepositoryName, main.Object.Sha, branch.Object.Sha); Assert.Equal(1, result.Commits.Count); Assert.Equal(1, result.AheadBy); @@ -412,10 +412,10 @@ public class RepositoryCommitsClientTests { await CreateTheWorld(); - var master = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/master"); + var main = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/main"); var branch = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/my-branch"); - var result = await _fixture.Compare(_context.Repository.Id, master.Object.Sha, branch.Object.Sha); + var result = await _fixture.Compare(_context.Repository.Id, main.Object.Sha, branch.Object.Sha); Assert.Equal(1, result.Commits.Count); Assert.Equal(1, result.AheadBy); @@ -444,18 +444,18 @@ public class RepositoryCommitsClientTests async Task CreateTheWorld() { - var master = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/master"); + var main = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/main"); - // create new commit for master branch - var newMasterTree = await CreateTree(new Dictionary { { "README.md", "Hello World!" } }); - var newMaster = await CreateCommit("baseline for pull request", newMasterTree.Sha, master.Object.Sha); + // create new commit for main branch + var newMainTree = await CreateTree(new Dictionary { { "README.md", "Hello World!" } }); + var newMain = await CreateCommit("baseline for pull request", newMainTree.Sha, main.Object.Sha); - // update master - await _github.Git.Reference.Update(Helper.UserName, _context.RepositoryName, "heads/master", new ReferenceUpdate(newMaster.Sha)); + // update main + await _github.Git.Reference.Update(Helper.UserName, _context.RepositoryName, "heads/main", new ReferenceUpdate(newMain.Sha)); // create new commit for feature branch var featureBranchTree = await CreateTree(new Dictionary { { "README.md", "I am overwriting this blob with something new" } }); - var newFeature = await CreateCommit("this is the commit to merge into the pull request", featureBranchTree.Sha, newMaster.Sha); + var newFeature = await CreateCommit("this is the commit to merge into the pull request", featureBranchTree.Sha, newMain.Sha); // create branch return await _github.Git.Reference.Create(Helper.UserName, _context.RepositoryName, new NewReference("refs/heads/my-branch", newFeature.Sha)); diff --git a/Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs index 099209d1..0501c092 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs @@ -73,7 +73,7 @@ namespace Octokit.Tests.Integration.Clients Assert.Equal(1, contents.Count); Assert.Equal(ContentType.File, contents.First().Type); - Assert.Equal("https://github.com/octokit/octokit.net/blob/master/Octokit.Reactive/ObservableGitHubClient.cs", contents.First().HtmlUrl); + Assert.Equal("https://github.com/octokit/octokit.net/blob/main/Octokit.Reactive/ObservableGitHubClient.cs", contents.First().HtmlUrl); } [IntegrationTest] @@ -88,7 +88,7 @@ namespace Octokit.Tests.Integration.Clients Assert.Equal(1, contents.Count); Assert.Equal(ContentType.File, contents.First().Type); - Assert.Equal("https://github.com/octokit/octokit.net/blob/master/Octokit.Reactive/ObservableGitHubClient.cs", contents.First().HtmlUrl); + Assert.Equal("https://github.com/octokit/octokit.net/blob/main/Octokit.Reactive/ObservableGitHubClient.cs", contents.First().HtmlUrl); } [IntegrationTest] @@ -131,7 +131,7 @@ namespace Octokit.Tests.Integration.Clients Assert.Equal(3, contents.Count); Assert.Equal(ContentType.File, contents.First().Type); - Assert.Equal("https://github.com/octocat/Spoon-Knife/blob/master/README.md", contents.First().HtmlUrl); + Assert.Equal("https://github.com/octocat/Spoon-Knife/blob/main/README.md", contents.First().HtmlUrl); } [IntegrationTest] @@ -146,7 +146,7 @@ namespace Octokit.Tests.Integration.Clients Assert.Equal(3, contents.Count); Assert.Equal(ContentType.File, contents.First().Type); - Assert.Equal("https://github.com/octocat/Spoon-Knife/blob/master/README.md", contents.First().HtmlUrl); + Assert.Equal("https://github.com/octocat/Spoon-Knife/blob/main/README.md", contents.First().HtmlUrl); } [IntegrationTest] @@ -186,11 +186,11 @@ namespace Octokit.Tests.Integration.Clients var contents = await github .Repository .Content - .GetAllContentsByRef("octokit", "octokit.net", "Octokit.Reactive/ObservableGitHubClient.cs", "master"); + .GetAllContentsByRef("octokit", "octokit.net", "Octokit.Reactive/ObservableGitHubClient.cs", "main"); Assert.Equal(1, contents.Count); Assert.Equal(ContentType.File, contents.First().Type); - Assert.Equal("https://github.com/octokit/octokit.net/blob/master/Octokit.Reactive/ObservableGitHubClient.cs", contents.First().HtmlUrl); + Assert.Equal("https://github.com/octokit/octokit.net/blob/main/Octokit.Reactive/ObservableGitHubClient.cs", contents.First().HtmlUrl); } [IntegrationTest] @@ -201,11 +201,11 @@ namespace Octokit.Tests.Integration.Clients var contents = await github .Repository .Content - .GetAllContentsByRef(7528679, "Octokit.Reactive/ObservableGitHubClient.cs", "master"); + .GetAllContentsByRef(7528679, "Octokit.Reactive/ObservableGitHubClient.cs", "main"); Assert.Equal(1, contents.Count); Assert.Equal(ContentType.File, contents.First().Type); - Assert.Equal("https://github.com/octokit/octokit.net/blob/master/Octokit.Reactive/ObservableGitHubClient.cs", contents.First().HtmlUrl); + Assert.Equal("https://github.com/octokit/octokit.net/blob/main/Octokit.Reactive/ObservableGitHubClient.cs", contents.First().HtmlUrl); } [IntegrationTest] @@ -237,7 +237,7 @@ namespace Octokit.Tests.Integration.Clients } [IntegrationTest] - public async Task GetsContentNonMasterWithRootPath() + public async Task GetsContentNonMainWithRootPath() { var github = Helper.GetAuthenticatedClient(); @@ -256,7 +256,7 @@ namespace Octokit.Tests.Integration.Clients var contents = await github .Repository .Content - .GetAllContentsByRef(7528679, "Octokit", "master"); + .GetAllContentsByRef(7528679, "Octokit", "main"); Assert.True(contents.Count > 2); Assert.Equal(ContentType.Dir, contents.First().Type); @@ -270,11 +270,11 @@ namespace Octokit.Tests.Integration.Clients var contents = await github .Repository .Content - .GetAllContentsByRef("octocat", "Spoon-Knife", "master"); + .GetAllContentsByRef("octocat", "Spoon-Knife", "main"); Assert.Equal(3, contents.Count); Assert.Equal(ContentType.File, contents.First().Type); - Assert.Equal("https://github.com/octocat/Spoon-Knife/blob/master/README.md", contents.First().HtmlUrl); + Assert.Equal("https://github.com/octocat/Spoon-Knife/blob/main/README.md", contents.First().HtmlUrl); } [IntegrationTest] @@ -285,11 +285,11 @@ namespace Octokit.Tests.Integration.Clients var contents = await github .Repository .Content - .GetAllContentsByRef(1300192, "master"); + .GetAllContentsByRef(1300192, "main"); Assert.Equal(3, contents.Count); Assert.Equal(ContentType.File, contents.First().Type); - Assert.Equal("https://github.com/octocat/Spoon-Knife/blob/master/README.md", contents.First().HtmlUrl); + Assert.Equal("https://github.com/octocat/Spoon-Knife/blob/main/README.md", contents.First().HtmlUrl); } [IntegrationTest] @@ -300,7 +300,7 @@ namespace Octokit.Tests.Integration.Clients var contents = await github .Repository .Content - .GetAllContentsByRef("octocat", "octocat.github.io", "master"); + .GetAllContentsByRef("octocat", "octocat.github.io", "main"); Assert.NotEmpty(contents); } @@ -313,7 +313,7 @@ namespace Octokit.Tests.Integration.Clients var contents = await github .Repository .Content - .GetAllContentsByRef(17881631, "master"); + .GetAllContentsByRef(17881631, "main"); Assert.NotEmpty(contents); } @@ -416,8 +416,8 @@ namespace Octokit.Tests.Integration.Clients { var repository = context.Repository; - var master = await client.Git.Reference.Get(Helper.UserName, repository.Name, "heads/master"); - await client.Git.Reference.Create(Helper.UserName, repository.Name, new NewReference("refs/heads/" + branchName, master.Object.Sha)); + var main = await client.Git.Reference.Get(Helper.UserName, repository.Name, "heads/main"); + await client.Git.Reference.Create(Helper.UserName, repository.Name, new NewReference("refs/heads/" + branchName, main.Object.Sha)); var file = await fixture.CreateFile( repository.Owner.Login, repository.Name, @@ -463,8 +463,8 @@ namespace Octokit.Tests.Integration.Clients { var repository = context.Repository; - var master = await client.Git.Reference.Get(Helper.UserName, repository.Name, "heads/master"); - await client.Git.Reference.Create(Helper.UserName, repository.Name, new NewReference("refs/heads/" + branchName, master.Object.Sha)); + var main = await client.Git.Reference.Get(Helper.UserName, repository.Name, "heads/main"); + await client.Git.Reference.Create(Helper.UserName, repository.Name, new NewReference("refs/heads/" + branchName, main.Object.Sha)); var file = await fixture.CreateFile( repository.Id, "somefile.txt", @@ -592,8 +592,8 @@ namespace Octokit.Tests.Integration.Clients { var repository = context.Repository; - var master = await client.Git.Reference.Get(Helper.UserName, repository.Name, "heads/master"); - await client.Git.Reference.Create(Helper.UserName, repository.Name, new NewReference("refs/heads/" + branchName, master.Object.Sha)); + var main = await client.Git.Reference.Get(Helper.UserName, repository.Name, "heads/main"); + await client.Git.Reference.Create(Helper.UserName, repository.Name, new NewReference("refs/heads/" + branchName, main.Object.Sha)); var file = await fixture.CreateFile( repository.Owner.Login, repository.Name, @@ -639,8 +639,8 @@ namespace Octokit.Tests.Integration.Clients { var repository = context.Repository; - var master = await client.Git.Reference.Get(Helper.UserName, repository.Name, "heads/master"); - await client.Git.Reference.Create(Helper.UserName, repository.Name, new NewReference("refs/heads/" + branchName, master.Object.Sha)); + var main = await client.Git.Reference.Get(Helper.UserName, repository.Name, "heads/main"); + await client.Git.Reference.Create(Helper.UserName, repository.Name, new NewReference("refs/heads/" + branchName, main.Object.Sha)); var file = await fixture.CreateFile( repository.Id, "somefile.txt", @@ -733,7 +733,7 @@ namespace Octokit.Tests.Integration.Clients var archive = await github .Repository .Content - .GetArchive("octocat", "Hello-World", ArchiveFormat.Tarball, "master"); + .GetArchive("octocat", "Hello-World", ArchiveFormat.Tarball, "main"); Assert.NotEmpty(archive); } @@ -746,7 +746,7 @@ namespace Octokit.Tests.Integration.Clients var archive = await github .Repository .Content - .GetArchive(1296269, ArchiveFormat.Tarball, "master"); // octocat/Hello-World repo + .GetArchive(1296269, ArchiveFormat.Tarball, "main"); // octocat/Hello-World repo Assert.NotEmpty(archive); } @@ -759,7 +759,7 @@ namespace Octokit.Tests.Integration.Clients var archive = await github .Repository .Content - .GetArchive("octocat", "Hello-World", ArchiveFormat.Tarball, "master", TimeSpan.FromMinutes(60)); + .GetArchive("octocat", "Hello-World", ArchiveFormat.Tarball, "main", TimeSpan.FromMinutes(60)); Assert.NotEmpty(archive); } @@ -772,7 +772,7 @@ namespace Octokit.Tests.Integration.Clients var archive = await github .Repository .Content - .GetArchive(1296269, ArchiveFormat.Tarball, "master", TimeSpan.FromMinutes(60)); // octocat/Hello-World repo + .GetArchive(1296269, ArchiveFormat.Tarball, "main", TimeSpan.FromMinutes(60)); // octocat/Hello-World repo Assert.NotEmpty(archive); } diff --git a/Octokit.Tests.Integration/Clients/RepositoryDeployKeysClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryDeployKeysClientTests.cs index b9e29ae4..36ed67a1 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryDeployKeysClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryDeployKeysClientTests.cs @@ -19,7 +19,7 @@ public class RepositoryDeployKeysClientTests : IDisposable var github = Helper.GetAuthenticatedClient(); _fixture = github.Repository.DeployKeys; - _context = github.CreateRepositoryContext("public-repo").Result; + _context = github.CreateRepositoryContextWithAutoInit("public-repo").Result; } [IntegrationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for investigating this failing test")] diff --git a/Octokit.Tests.Integration/Clients/SearchClientTests.cs b/Octokit.Tests.Integration/Clients/SearchClientTests.cs index 506da6f7..c64d6a02 100644 --- a/Octokit.Tests.Integration/Clients/SearchClientTests.cs +++ b/Octokit.Tests.Integration/Clients/SearchClientTests.cs @@ -640,7 +640,7 @@ public class SearchClientTests [IntegrationTest] public async Task SearchForExcludedBase() { - var branch = "master"; + var branch = "main"; // Search for issues by target branch var request = new SearchIssuesRequest(); diff --git a/Octokit.Tests.Integration/Clients/StatisticsClientTests.cs b/Octokit.Tests.Integration/Clients/StatisticsClientTests.cs index 7efca125..9809e7ce 100644 --- a/Octokit.Tests.Integration/Clients/StatisticsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/StatisticsClientTests.cs @@ -19,7 +19,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task CanCreateAndRetrieveContributors() { - using (var context = await _client.CreateRepositoryContext("public-repo")) + using (var context = await _client.CreateRepositoryContextWithAutoInit("public-repo")) { var repository = new RepositorySummary(context); await CommitToRepository(repository); @@ -40,7 +40,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task CanCreateAndRetrieveContributorsWithRepositoryId() { - using (var context = await _client.CreateRepositoryContext("public-repo")) + using (var context = await _client.CreateRepositoryContextWithAutoInit("public-repo")) { var repository = new RepositorySummary(context); await CommitToRepository(repository); @@ -88,7 +88,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task CanGetCommitActivityForTheLastYear() { - using (var context = await _client.CreateRepositoryContext("public-repo")) + using (var context = await _client.CreateRepositoryContextWithAutoInit("public-repo")) { var repository = new RepositorySummary(context); await CommitToRepository(repository); @@ -106,7 +106,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task CanGetCommitActivityForTheLastYearWithRepositoryId() { - using (var context = await _client.CreateRepositoryContext("public-repo")) + using (var context = await _client.CreateRepositoryContextWithAutoInit("public-repo")) { var repository = new RepositorySummary(context); await CommitToRepository(repository); @@ -124,7 +124,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task CanGetAdditionsAndDeletionsPerWeek() { - using (var context = await _client.CreateRepositoryContext("public-repo")) + using (var context = await _client.CreateRepositoryContextWithAutoInit("public-repo")) { var repository = new RepositorySummary(context); await CommitToRepository(repository); @@ -137,7 +137,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task CanGetAdditionsAndDeletionsPerWeekWithRepositoryId() { - using (var context = await _client.CreateRepositoryContext("public-repo")) + using (var context = await _client.CreateRepositoryContextWithAutoInit("public-repo")) { var repository = new RepositorySummary(context); await CommitToRepository(repository); @@ -151,7 +151,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task CanGetParticipationStatistics() { - using (var context = await _client.CreateRepositoryContext("public-repo")) + using (var context = await _client.CreateRepositoryContextWithAutoInit("public-repo")) { var repository = new RepositorySummary(context); await CommitToRepository(repository); @@ -163,7 +163,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task CanGetParticipationStatisticsWithRepositoryId() { - using (var context = await _client.CreateRepositoryContext("public-repo")) + using (var context = await _client.CreateRepositoryContextWithAutoInit("public-repo")) { var repository = new RepositorySummary(context); await CommitToRepository(repository); @@ -175,7 +175,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task CanGetPunchCardForRepository() { - using (var context = await _client.CreateRepositoryContext("public-repo")) + using (var context = await _client.CreateRepositoryContextWithAutoInit("public-repo")) { var repository = new RepositorySummary(context); await CommitToRepository(repository); @@ -188,7 +188,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task CanGetPunchCardForRepositoryWithRepositoryId() { - using (var context = await _client.CreateRepositoryContext("public-repo")) + using (var context = await _client.CreateRepositoryContextWithAutoInit("public-repo")) { var repository = new RepositorySummary(context); await CommitToRepository(repository); diff --git a/Octokit.Tests.Integration/Clients/TagsClientTests.cs b/Octokit.Tests.Integration/Clients/TagsClientTests.cs index 3fc83ee5..3aedbaf0 100644 --- a/Octokit.Tests.Integration/Clients/TagsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/TagsClientTests.cs @@ -17,7 +17,7 @@ namespace Octokit.Tests.Integration.Clients var github = Helper.GetAuthenticatedClient(); fixture = github.Git.Tag; - context = github.CreateRepositoryContext("public-repo").Result; + context = github.CreateRepositoryContextWithAutoInit("public-repo").Result; var blob = new NewBlob { @@ -65,7 +65,7 @@ namespace Octokit.Tests.Integration.Clients var github = Helper.GetAuthenticatedClient(); fixture = github.Git.Tag; - context = github.CreateRepositoryContext("public-repo").Result; + context = github.CreateRepositoryContextWithAutoInit("public-repo").Result; var blob = new NewBlob { diff --git a/Octokit.Tests.Integration/Clients/TreeClientTests.cs b/Octokit.Tests.Integration/Clients/TreeClientTests.cs index ea7d2b7e..a069bb44 100644 --- a/Octokit.Tests.Integration/Clients/TreeClientTests.cs +++ b/Octokit.Tests.Integration/Clients/TreeClientTests.cs @@ -17,7 +17,7 @@ public class TreeClientTests : IDisposable _fixture = _github.Git.Tree; - _context = _github.CreateRepositoryContext("public-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("public-repo").Result; } [IntegrationTest] @@ -73,7 +73,7 @@ public class TreeClientTests : IDisposable [IntegrationTest] public async Task CanGetATree() { - var result = await _fixture.Get("octokit", "octokit.net", "master"); + var result = await _fixture.Get("octokit", "octokit.net", "main"); Assert.NotNull(result); Assert.NotEmpty(result.Tree); @@ -82,7 +82,7 @@ public class TreeClientTests : IDisposable [IntegrationTest] public async Task CanGetATreeWithRepositoryId() { - var result = await _fixture.Get(1, "master"); + var result = await _fixture.Get(1, "main"); Assert.NotNull(result); Assert.NotEmpty(result.Tree); diff --git a/Octokit.Tests.Integration/Clients/WatchedClientTests.cs b/Octokit.Tests.Integration/Clients/WatchedClientTests.cs index e49f186a..beb067a0 100644 --- a/Octokit.Tests.Integration/Clients/WatchedClientTests.cs +++ b/Octokit.Tests.Integration/Clients/WatchedClientTests.cs @@ -299,7 +299,7 @@ namespace Octokit.Tests.Integration.Clients _watchingClient = github.Activity.Watching; - _context = github.CreateRepositoryContext("public-repo").Result; + _context = github.CreateRepositoryContextWithAutoInit("public-repo").Result; } [IntegrationTest] diff --git a/Octokit.Tests.Integration/Helper.cs b/Octokit.Tests.Integration/Helper.cs index 455b8a7d..2bc13c74 100644 --- a/Octokit.Tests.Integration/Helper.cs +++ b/Octokit.Tests.Integration/Helper.cs @@ -247,6 +247,8 @@ namespace Octokit.Tests.Integration return string.Concat(name, "-", DateTime.UtcNow.ToString("yyyyMMddhhmmssfff")); } + public static bool IsNameTimestamped(string name) => name.Contains("-") && name.Substring(name.LastIndexOf("-")).Length == 18; + public static Stream LoadFixture(string fileName) { var key = "Octokit.Tests.Integration.fixtures." + fileName; diff --git a/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs b/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs index a30f4e62..941aeb93 100644 --- a/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs +++ b/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs @@ -1,26 +1,24 @@ -using System.Threading.Tasks; +using System; +using System.Threading.Tasks; namespace Octokit.Tests.Integration.Helpers { internal static class GithubClientExtensions { /// - /// Creates a public repository with the timestamped name public-repo + /// Creates a public repository with the timestamped name public-repo and autoinit true /// - internal static async Task CreateRepositoryContext(this IGitHubClient client) + internal static async Task CreateRepositoryContextWithAutoInit(this IGitHubClient client) { - var repoName = Helper.MakeNameWithTimestamp("public-repo"); - var repo = await client.Repository.Create(new NewRepository(repoName) { AutoInit = true }); - - return new RepositoryContext(client.Connection, repo); + return await client.CreateUserRepositoryContext(x => x.AutoInit = true); } - internal static async Task CreateRepositoryContext(this IGitHubClient client, string repositoryName) + /// + /// Creates a public repository with the repository name passed in and autoinit true + /// + internal static async Task CreateRepositoryContextWithAutoInit(this IGitHubClient client, string repositoryName) { - var repoName = Helper.MakeNameWithTimestamp(repositoryName); - var repo = await client.Repository.Create(new NewRepository(repoName) { AutoInit = true }); - - return new RepositoryContext(client.Connection, repo); + return await client.CreateUserRepositoryContext(Helper.MakeNameWithTimestamp(repositoryName), x => x.AutoInit = true); } internal static async Task CreateRepositoryContext(this IGitHubClient client, NewRepository newRepository) @@ -31,9 +29,69 @@ namespace Octokit.Tests.Integration.Helpers } /// - /// Creates an organisationrepository with the timestamped name organisation-repo + /// Creates a public repository with the timestamped name "public-repo" and an optional function of parameters passed in /// - internal static async Task CreateOrganizationRepositoryContext(this IGitHubClient client) + /// + /// The name of the repository without the timestamp + /// Function setting parameters on the NewRepository + /// + internal static async Task CreateUserRepositoryContext(this IGitHubClient client, Action action = null) + { + var newRepository = new NewRepository(Helper.MakeNameWithTimestamp("public-repo")); + action?.Invoke(newRepository); + + var repo = await client.Repository.Create(newRepository); + + return new RepositoryContext(client.Connection, repo); + } + + /// + /// Creates a public repository with the repository name and an optional function of parameters passed in + /// + /// + /// The name of the repository without the timestamp + /// + /// + internal static async Task CreateUserRepositoryContext(this IGitHubClient client, string repositoryName, Action action = null) + { + var newRepository = new NewRepository(Helper.IsNameTimestamped(repositoryName) ? repositoryName : Helper.MakeNameWithTimestamp(repositoryName)); + action?.Invoke(newRepository); + + var repo = await client.Repository.Create(newRepository); + + return new RepositoryContext(client.Connection, repo); + } + + /// + /// Creates an organisation repository with the timestamped name organisation-repo and an optional function of parameters + /// + internal static async Task CreateOrganizationRepositoryContext(this IGitHubClient client, Action action = null) + { + var newRepository = new NewRepository(Helper.MakeNameWithTimestamp("organization-repo")); + action?.Invoke(newRepository); + + var repo = await client.Repository.Create(Helper.Organization, newRepository); + + return new RepositoryContext(client.Connection, repo); + } + + /// + /// Creates an organisation repository with the passed in repository name repo and an optional function of parameters + /// + internal static async Task CreateOrganizationRepositoryContext(this IGitHubClient client, string repositoryName, Action action = null) + { + var newRepository = new NewRepository(Helper.IsNameTimestamped(repositoryName) ? repositoryName : Helper.MakeNameWithTimestamp(repositoryName)); + action?.Invoke(newRepository); + + var repo = await client.Repository.Create(Helper.Organization, newRepository); + + return new RepositoryContext(client.Connection, repo); + } + + /// + /// Creates an organisation repository with the timestamped name organisation-repo + /// + internal static async Task CreateOrganizationRepositoryContextWithAutoInit(this IGitHubClient client, Action action = null) { var repoName = Helper.MakeNameWithTimestamp("organization-repo"); var repo = await client.Repository.Create(Helper.Organization, new NewRepository(repoName) { AutoInit = true }); @@ -51,6 +109,17 @@ namespace Octokit.Tests.Integration.Helpers return new RepositoryContext(client.Connection, repo); } + /// + /// Creates a private repository with the timestamped name private-repo + /// + internal static async Task CreatePrivateRepositoryContext(this IGitHubClient client) + { + var repoName = Helper.MakeNameWithTimestamp("private-repo"); + var repo = await client.Repository.Create(new NewRepository(repoName) { Private = true }); + + return new RepositoryContext(client.Connection, repo); + } + internal static async Task Generate(this IGitHubClient client, string owner, string repoName, NewRepositoryFromTemplate newRepository) { var repo = await client.Repository.Generate(owner, repoName, newRepository); diff --git a/Octokit.Tests.Integration/Helpers/PaidAccountTestAttribute.cs b/Octokit.Tests.Integration/Helpers/PaidAccountTestAttribute.cs index 01d1ae16..952b8fdf 100644 --- a/Octokit.Tests.Integration/Helpers/PaidAccountTestAttribute.cs +++ b/Octokit.Tests.Integration/Helpers/PaidAccountTestAttribute.cs @@ -23,6 +23,14 @@ namespace Octokit.Tests.Integration if (!Helper.IsPaidAccount) return Enumerable.Empty(); + var github = Helper.GetAuthenticatedClient(); + + var userDetails = github.User.Current().Result; + if (userDetails.Plan.PrivateRepos == 0) + { + return Enumerable.Empty(); + } + return new[] { new XunitTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod) }; } } diff --git a/Octokit.Tests.Integration/Helpers/ReferenceExtensionsTests.cs b/Octokit.Tests.Integration/Helpers/ReferenceExtensionsTests.cs index 3a7f9113..19eeddd6 100644 --- a/Octokit.Tests.Integration/Helpers/ReferenceExtensionsTests.cs +++ b/Octokit.Tests.Integration/Helpers/ReferenceExtensionsTests.cs @@ -13,11 +13,11 @@ namespace Octokit.Tests.Integration.Helpers var client = Helper.GetAuthenticatedClient(); var fixture = client.Git.Reference; - using (var context = await client.CreateRepositoryContext("public-repo")) + using (var context = await client.CreateRepositoryContextWithAutoInit("public-repo")) { - var branchFromMaster = await fixture.CreateBranch(context.RepositoryOwner, context.RepositoryName, "patch-1", context.Repository.DefaultBranch); + var branchFromMain = await fixture.CreateBranch(context.RepositoryOwner, context.RepositoryName, "patch-1", context.Repository.DefaultBranch); - var branchFromPath = await fixture.CreateBranch(context.RepositoryOwner, context.RepositoryName, "patch-2", branchFromMaster); + var branchFromPath = await fixture.CreateBranch(context.RepositoryOwner, context.RepositoryName, "patch-2", branchFromMain); var allBranchNames = (await client.Repository.Branch.GetAll(context.RepositoryOwner, context.RepositoryName)).Select(b => b.Name); diff --git a/Octokit.Tests.Integration/Helpers/RepositorySetupHelper.cs b/Octokit.Tests.Integration/Helpers/RepositorySetupHelper.cs index 3bfa7f4d..49cbe1d8 100644 --- a/Octokit.Tests.Integration/Helpers/RepositorySetupHelper.cs +++ b/Octokit.Tests.Integration/Helpers/RepositorySetupHelper.cs @@ -44,18 +44,18 @@ namespace Octokit.Tests.Integration.Helpers public static async Task CreateTheWorld(this IGitHubClient client, Repository repository) { - var master = await client.Git.Reference.Get(repository.Owner.Login, repository.Name, "heads/master"); + var main = await client.Git.Reference.Get(repository.Owner.Login, repository.Name, "heads/main"); - // create new commit for master branch - var newMasterTree = await client.CreateTree(repository, new Dictionary { { "README.md", "Hello World!" } }); - var newMaster = await client.CreateCommit(repository, "baseline for pull request", newMasterTree.Sha, master.Object.Sha); + // create new commit for main branch + var newMainTree = await client.CreateTree(repository, new Dictionary { { "README.md", "Hello World!" } }); + var newMain = await client.CreateCommit(repository, "baseline for pull request", newMainTree.Sha, main.Object.Sha); - // update master - await client.Git.Reference.Update(repository.Owner.Login, repository.Name, "heads/master", new ReferenceUpdate(newMaster.Sha)); + // update main + await client.Git.Reference.Update(repository.Owner.Login, repository.Name, "heads/main", new ReferenceUpdate(newMain.Sha)); // create new commit for feature branch var featureBranchTree = await client.CreateTree(repository, new Dictionary { { "README.md", "I am overwriting this blob with something new\nand a second line too" } }); - var featureBranchCommit = await client.CreateCommit(repository, "this is the commit to merge into the pull request", featureBranchTree.Sha, newMaster.Sha); + var featureBranchCommit = await client.CreateCommit(repository, "this is the commit to merge into the pull request", featureBranchTree.Sha, newMain.Sha); // create branch return await client.Git.Reference.Create(repository.Owner.Login, repository.Name, new NewReference("refs/heads/my-branch", featureBranchCommit.Sha)); @@ -63,7 +63,7 @@ namespace Octokit.Tests.Integration.Helpers public static async Task CreatePullRequest(this IGitHubClient client, Repository repository, string branch = "my-branch") { - var pullRequest = new NewPullRequest("Nice title for the pull request", branch, "master"); + var pullRequest = new NewPullRequest("Nice title for the pull request", branch, "main"); var createdPullRequest = await client.PullRequest.Create(repository.Owner.Login, repository.Name, pullRequest); return createdPullRequest; diff --git a/Octokit.Tests.Integration/PotentiallyFlakyTestAttribute.cs b/Octokit.Tests.Integration/PotentiallyFlakyTestAttribute.cs new file mode 100644 index 00000000..4de5e698 --- /dev/null +++ b/Octokit.Tests.Integration/PotentiallyFlakyTestAttribute.cs @@ -0,0 +1,13 @@ +using System; + +namespace Octokit.Tests.Integration +{ + /// + /// A potentially flaky test could be: + /// * Calls for details of repositories which already exist and was not created by the test itself (so could disappear over time) + /// * Calls for details of users which already exist (so could disappear over time) + /// + public class PotentiallyFlakyTestAttribute : Attribute + { + } +} diff --git a/Octokit.Tests.Integration/Reactive/ObservableCheckRunsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableCheckRunsClientTests.cs index c7b95c49..dad48855 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableCheckRunsClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableCheckRunsClientTests.cs @@ -29,7 +29,7 @@ namespace Octokit.Tests.Integration.Reactive using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -51,7 +51,7 @@ namespace Octokit.Tests.Integration.Reactive using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -87,7 +87,7 @@ namespace Octokit.Tests.Integration.Reactive using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -119,7 +119,7 @@ namespace Octokit.Tests.Integration.Reactive using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -165,7 +165,7 @@ namespace Octokit.Tests.Integration.Reactive using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -200,7 +200,7 @@ namespace Octokit.Tests.Integration.Reactive using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -249,7 +249,7 @@ namespace Octokit.Tests.Integration.Reactive using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -284,7 +284,7 @@ namespace Octokit.Tests.Integration.Reactive using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -401,7 +401,7 @@ namespace Octokit.Tests.Integration.Reactive using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -434,7 +434,7 @@ namespace Octokit.Tests.Integration.Reactive using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch diff --git a/Octokit.Tests.Integration/Reactive/ObservableCheckSuitesClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableCheckSuitesClientTests.cs index 68cc68df..b9b44c28 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableCheckSuitesClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableCheckSuitesClientTests.cs @@ -28,7 +28,7 @@ namespace Octokit.Tests.Integration.Reactive using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Need to get a CheckSuiteId so we can test the Get method - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, "main"); var checkSuite = (await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha)).CheckSuites.First(); // Get Check Suite by Id @@ -46,7 +46,7 @@ namespace Octokit.Tests.Integration.Reactive using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Need to get a CheckSuiteId so we can test the Get method - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var checkSuite = (await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryId, headCommit.Sha)).CheckSuites.First(); // Get Check Suite by Id @@ -77,7 +77,7 @@ namespace Octokit.Tests.Integration.Reactive { using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, "main"); var checkSuites = await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha); @@ -94,7 +94,7 @@ namespace Octokit.Tests.Integration.Reactive { using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var checkSuites = await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryId, headCommit.Sha); @@ -178,7 +178,7 @@ namespace Octokit.Tests.Integration.Reactive await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryOwner, repoContext.RepositoryName, preference); // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, "main"); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check suite for the feature branch @@ -201,7 +201,7 @@ namespace Octokit.Tests.Integration.Reactive await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryId, preference); // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check suite for the feature branch @@ -234,7 +234,7 @@ namespace Octokit.Tests.Integration.Reactive using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Need to get a CheckSuiteId so we can test the Get method - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var checkSuite = (await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryId, headCommit.Sha)).CheckSuites.First(); var result = await _githubAppInstallation.Check.Suite.Rerequest(repoContext.RepositoryOwner, repoContext.RepositoryName, checkSuite.Id); @@ -249,7 +249,7 @@ namespace Octokit.Tests.Integration.Reactive using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Need to get a CheckSuiteId so we can test the Get method - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var checkSuite = (await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryId, headCommit.Sha)).CheckSuites.First(); var result = await _githubAppInstallation.Check.Suite.Rerequest(repoContext.RepositoryId, checkSuite.Id);