From 232b750739c26a7c39d6f5b228682761cf3d9a2b Mon Sep 17 00:00:00 2001 From: Chris Simpson Date: Thu, 21 Jul 2022 06:00:01 +0100 Subject: [PATCH] Updates and fixes for tests, changing master to main and adding flaky tests marker Tidying up RepositoryClientTests Marking flaky tests and complete repositories client tests upgrades. Some do not work! Renaming remaining master to main and performing light touch tests Rebase fixes --- .../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 | 91 ++++++++-- .../Helpers/PaidAccountTestAttribute.cs | 8 + .../Helpers/ReferenceExtensionsTests.cs | 6 +- .../Helpers/RepositorySetupHelper.cs | 16 +- .../PotentiallyFlakyTestAttribute.cs | 13 ++ .../ObservableCheckRunsClientTests.cs | 20 +-- .../ObservableCheckSuitesClientTests.cs | 16 +- 36 files changed, 491 insertions(+), 488 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 d0a3a9f87c..8aeaf306b0 100644 --- a/Octokit.Tests.Integration/Clients/BlobClientTests.cs +++ b/Octokit.Tests.Integration/Clients/BlobClientTests.cs @@ -16,7 +16,7 @@ public BlobClientTests() 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 237e998841..fe008cecb4 100644 --- a/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs @@ -18,7 +18,7 @@ public TheCreateReactionMethod() { _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 8f00b43f55..3cccfd7fec 100644 --- a/Octokit.Tests.Integration/Clients/CommitStatusClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CommitStatusClientTests.cs @@ -213,7 +213,7 @@ public TheCreateMethod() { _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 c2759a7fd7..166355368a 100644 --- a/Octokit.Tests.Integration/Clients/CommitsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CommitsClientTests.cs @@ -12,7 +12,7 @@ public async Task CanCreateAndRetrieveCommit() 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 async Task CanCreateAndRetrieveCommitWithRepositoryId() 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 3d19b48ed9..1fa4b89943 100644 --- a/Octokit.Tests.Integration/Clients/DeploymentStatusClientTests.cs +++ b/Octokit.Tests.Integration/Clients/DeploymentStatusClientTests.cs @@ -16,7 +16,7 @@ public DeploymentStatusClientTests() 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 a0bc2d0d71..43902fed25 100644 --- a/Octokit.Tests.Integration/Clients/DeploymentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/DeploymentsClientTests.cs @@ -17,7 +17,7 @@ public DeploymentsClientTests() 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 168b9c087f..b9343e46c6 100644 --- a/Octokit.Tests.Integration/Clients/IssueCommentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssueCommentsClientTests.cs @@ -45,7 +45,7 @@ public async Task ReturnsIssueCommentWithRepositoryId() [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 async Task ReturnsDistinctResultsBasedOnStartPageWithRepositoryId() 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 async Task ReturnsDistinctResultsBasedOnStartPageWithRepositoryId() 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 2d887ed027..88a793f200 100644 --- a/Octokit.Tests.Integration/Clients/IssuesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssuesClientTests.cs @@ -1288,7 +1288,7 @@ public async Task GetAllForOrganizationContainsRepositoryData() [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 async Task CanGetReactionPayload() 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 dcbc5be983..66cc557828 100644 --- a/Octokit.Tests.Integration/Clients/MergingClientTests.cs +++ b/Octokit.Tests.Integration/Clients/MergingClientTests.cs @@ -22,7 +22,7 @@ public MergingClientTests() }; _fixture = _github.Repository.Merging; - _context = _github.CreateRepositoryContext("public-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("public-repo").Result; } [IntegrationTest] @@ -30,12 +30,12 @@ public async Task CanCreateMerge() { 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 async Task CanCreateMergeWithRepositoryId() { 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 c48cf6757f..97568ead56 100644 --- a/Octokit.Tests.Integration/Clients/ProjectCardsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/ProjectCardsClientTests.cs @@ -203,7 +203,7 @@ public TheCreateMethod() { _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 3e05118458..a6a05c8871 100644 --- a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs @@ -25,7 +25,7 @@ public PullRequestReviewCommentReactionsClientTests() _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 async Task CanCreateReactionWithRepositoryId() 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 @@ async Task CreatePullRequest(RepositoryContext context) // 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 @@ async Task CreatePullRequest(RepositoryContext context) // 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 ad51225dbe..82e2f9bb5e 100644 --- a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentsClientTests.cs @@ -23,7 +23,7 @@ public PullRequestReviewCommentsClientTests() _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 @@ static void AssertComments(IReadOnlyList comments, Lis } /// - /// 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 @@ async Task CreatePullRequest(RepositoryContext context, string 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 @@ async Task CreatePullRequest(RepositoryContext context, string // 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 @@ class PullRequestData 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 async Task CanGetReactionPayloadForPullRequestReviews() 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 4c20d2e90f..c0ee6c0b49 100644 --- a/Octokit.Tests.Integration/Clients/PullRequestReviewRequestsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/PullRequestReviewRequestsClientTests.cs @@ -26,7 +26,7 @@ public PullRequestReviewRequestClientTestsBase() _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 async Task CreatesRequestsWithRepositoryId() 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 @@ static async Task CreateTheWorld(IGitHubClient github, RepositoryContext co 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 3b7d521750..5e57ca592d 100644 --- a/Octokit.Tests.Integration/Clients/PullRequestReviewsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/PullRequestReviewsClientTests.cs @@ -126,7 +126,7 @@ public TheCreateMethod() [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 async Task CanCreatePendingReview() [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 async Task CanCreatePendingReviewWithRepositoryId() [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 async Task CanCreateCommentedReview() [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 async Task CanCreateCommentedReviewWithRepositoryId() [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 async Task CanCreateChangesRequestedReview() [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 async Task CanCreateChangesRequestedReviewWithRepositoryId() [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 async Task CanCreateApprovedReview() [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 TheDeleteMethod() [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 async Task CanDeleteReview() [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 TheDismissMethod() [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 async Task CanDismissReview() [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 TheSubmitMethod() [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 async Task CanSubmitCommentedReview() [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 async Task CanSubmitCommentedReviewWithRepositoryId() [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 async Task CanSubmitChangesRequestedReview() [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 async Task CanSubmitChangesRequestedReviewWithRepositoryId() [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 async Task CanSubmitApprovedReview() [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 0b01c08507..8985e28b32 100644 --- a/Octokit.Tests.Integration/Clients/PullRequestsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/PullRequestsClientTests.cs @@ -25,7 +25,7 @@ public PullRequestsClientTests() _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 async Task CanCreate() { 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 async Task CanCreateDraft() { 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 async Task CanCreateFromIssue() 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 async Task CanCreateWithRepositoryId() { 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 async Task CanCreateDraftWithRepositoryId() { 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 async Task CanCreateFromIssueWithRepositoryId() 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 async Task CanGetForRepository() { 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 async Task CanGetDraftForRepository() { 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 async Task CanGetForRepositoryWithRepositoryId() { 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 async Task CanGetDraftForRepositoryWithRepositoryId() { 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 async Task CanGetWithAssigneesForRepository() { 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 async Task CanGetWithAssigneesForRepositoryWithRepositoryId() { 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 async Task CanGetWithLabelsForRepository() { 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 async Task CanGetWithLabelsForRepositoryWithRepositoryId() { 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 async Task ReturnsCorrectCountOfPullRequestsWithoutStart() { 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 async Task ReturnsCorrectCountOfPullRequestsWithoutStartWithRepositoryId( { 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 async Task ReturnsCorrectCountOfPullRequestsWithStart() { 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 async Task ReturnsCorrectCountOfPullRequestsWithStartWithRepositoryId() { 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 async Task ReturnsDistinctPullRequestsBasedOnStartPage() { 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 async Task ReturnsDistinctPullRequestsBasedOnStartPageWithRepositoryId() { 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 async Task CanGetOpenPullRequest() { 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 async Task CanGetOpenPullRequestWithRepositoryId() { 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 async Task ReturnsCorrectCountOfPullRequestsWithoutStartParameterized() { 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 async Task ReturnsCorrectCountOfPullRequestsWithoutStartParameterizedWith { 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 async Task ReturnsCorrectCountOfPullRequestsWithStartParameterized() { 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 async Task ReturnsCorrectCountOfPullRequestsWithStartParameterizedWithRep { 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 async Task ReturnsDistinctPullRequestsBasedOnStartPageParameterized() { 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 async Task ReturnsDistinctPullRequestsBasedOnStartPageParameterizedWithRe { 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 async Task IgnoresOpenPullRequest() { 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 async Task IgnoresOpenPullRequestWithRepositoryId() { 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 async Task CanUpdate() { 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 async Task CanUpdateWithRepositoryId() { 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 async Task CanClose() { 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 async Task CanFindClosedPullRequest() { 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 async Task CanSortPullRequests() { 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 async Task CanSpecifyDirectionOfSort() { 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 async Task IsNotMergedInitially() { 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 async Task IsNotMergedInitiallyWithRepositoryId() { 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 async Task CanBeMerged() { 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 async Task CanBeMergedWithRepositoryId() { 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 async Task CanBeMergedWithNoOptionalInput() { 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 async Task CanBeMergedWithShaSpecified() { 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 async Task CanBeMergedWithMergeMethod() { 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 async Task CanBeMergedWithSquashMethod() { 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 async Task CanBeMergedWithRebaseMethod() { 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 async Task CannotBeMergedDueMismatchConflict() 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 async Task CannotBeMergedDueNotInMergeableState() { 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 async Task CannotBeMergedDueNotInMergeableState() } [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 async Task CanBrowseCommits() { 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 async Task CanBrowseCommitsWithRepositoryId() { 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 async Task CanGetCommitsAndCommentCount() { 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 async Task CanGetCommitsAndCommentCountWithRepositoryId() { 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 async Task CanBrowseFilesWithRepositoryId() 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 @@ async Task CreateTheWorld() 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 9f2c62bdd2..94f6157b04 100644 --- a/Octokit.Tests.Integration/Clients/ReferencesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/ReferencesClientTests.cs @@ -18,17 +18,17 @@ public ReferencesClientTests() _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 async Task CanGetAReference() [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 58e3f6083e..258ec656f9 100644 --- a/Octokit.Tests.Integration/Clients/ReleasesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/ReleasesClientTests.cs @@ -32,7 +32,7 @@ public TheCreateReleasesMethod() 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 TheGetReleasesMethod() 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 TheEditMethod() _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 async Task CanChangeCommitIshOfRelease() 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 async Task CanChangeCommitIshOfReleaseWithRepositoryId() 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 TheUploadAssetMethod() _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 TheDeleteAssetsMethod() _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 TheDeleteMethod() _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 0093885264..ce2a9fa34d 100644 --- a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs @@ -511,7 +511,7 @@ public class TheEditMethod : GitHubClientTestBase [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 async Task UpdatesNothing() [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 async Task UpdatesName() [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 async Task UpdatesNameWithRepositoryId() [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 async Task UpdatesNameObsolete() [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 async Task UpdatesNameWithRepositoryIdObsolete() [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 async Task UpdatesDescription() [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 async Task UpdatesDescriptionWithRepositoryId() [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 async Task UpdatesHomepage() [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 async Task UpdatesHomepageWithRepositoryId() [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 async Task UpdatesPrivate() [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 async Task UpdatesPrivateWithRepositoryId() [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 async Task UpdatesHasIssues() [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 async Task UpdatesHasIssuesWithRepositoryId() [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 async Task UpdatesHasWiki() [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 async Task UpdatesHasWikiWithRepositoryId() [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 async Task UpdatesHasDownloads() [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 async Task UpdatesHasDownloadsWithRepositoryId() [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 async Task UpdatesIsTemplate() [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 async Task UpdatesIsTemplateWithRepositoryId() [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 async Task UpdatesDefaultBranch() [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 async Task UpdatesDefaultBranchWithRepositoryId() [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 async Task UpdatesMergeMethod() [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 async Task UpdatesMergeMethodWithRepositoryId() 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 async Task UpdatesDeleteBranchOnMergeMethodWithRepositoryId() [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 async Task UpdatesArchive() [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 async Task DeletesRepositoryWithRepositoryId() } } - public class TheGetMethod + public class TheGetMethod : GitHubClientTestBase { [IntegrationTest] + [PotentiallyFlakyTest] public async Task ReturnsSpecifiedRepository() { var github = Helper.GetAuthenticatedClient(); @@ -945,6 +948,7 @@ public async Task ReturnsSpecifiedRepository() } [IntegrationTest] + [PotentiallyFlakyTest] public async Task ReturnsSpecifiedRepositoryWithRepositoryId() { var github = Helper.GetAuthenticatedClient(); @@ -959,6 +963,7 @@ public async Task ReturnsSpecifiedRepositoryWithRepositoryId() } [IntegrationTest] + [PotentiallyFlakyTest] public async Task ReturnsOrganizationRepository() { var github = Helper.GetAuthenticatedClient(); @@ -972,6 +977,7 @@ public async Task ReturnsOrganizationRepository() } [IntegrationTest] + [PotentiallyFlakyTest] public async Task ReturnsRenamedRepository() { var github = Helper.GetAuthenticatedClient(); @@ -997,6 +1003,7 @@ public async Task ReturnsRenamedRepository() } [IntegrationTest] + [PotentiallyFlakyTest] public async Task ReturnsOrganizationRepositoryWithRepositoryId() { var github = Helper.GetAuthenticatedClient(); @@ -1010,6 +1017,7 @@ public async Task ReturnsOrganizationRepositoryWithRepositoryId() } [IntegrationTest] + [PotentiallyFlakyTest] public async Task ReturnsForkedRepository() { var github = Helper.GetAuthenticatedClient(); @@ -1021,6 +1029,7 @@ public async Task ReturnsForkedRepository() } [IntegrationTest] + [PotentiallyFlakyTest] public async Task ReturnsForkedRepositoryWithRepositoryId() { var github = Helper.GetAuthenticatedClient(); @@ -1036,7 +1045,7 @@ public async Task ReturnsRepositoryMergeOptions() { 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 async Task ReturnsRepositoryMergeOptionsWithRepositoryId() { 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 async Task ReturnsRepositoryMergeOptionsWithRepositoryId() } [IntegrationTest] + [PotentiallyFlakyTest] public async Task ReturnsSpecifiedRepositoryWithLicenseInformation() { var github = Helper.GetAuthenticatedClient(); @@ -1074,13 +1084,13 @@ public async Task ReturnsSpecifiedRepositoryWithLicenseInformation() 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 async Task ReturnsRepositoryDeleteBranchOnMergeOptionsWithRepositoryId() { 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 async Task CanChangeSortDirection() } } - public class TheGetAllLanguagesMethod + public class TheGetAllLanguagesMethod : GitHubClientTestBase { [IntegrationTest] public async Task GetsLanguages() @@ -1660,7 +1670,7 @@ public async Task GetsLanguagesWithRepositoryId() 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 async Task GetsEmptyLanguagesWhenNone() 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 async Task AreVulnerabilityAlertsEnabledReturnsTrue() 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 9632171bf3..f2798554fa 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs @@ -14,7 +14,7 @@ public class TheGetAllMethod : GitHubClientTestBase [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 @@ public async Task GetsAllBranches() [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 @@ public async Task GetsAllBranchesWithRepositoryId() [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 @@ public async Task ReturnsCorrectCountOfBranchesWithoutStart() [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 @@ public async Task ReturnsCorrectCountOfBranchesWithoutStartWithRepositoryId() [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 @@ public async Task ReturnsCorrectCountOfBranchesWithStart() [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 @@ public async Task ReturnsCorrectCountOfBranchesWithStartWithRepositoryId() [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 @@ public async Task GetsPagesOfBranches() [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 @@ public class TheGetMethod : GitHubClientTestBase [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 @@ public async Task GetsABranch() [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 @@ public class TheGetBranchProtectionMethod : GitHubClientTestBase [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 @@ public async Task GetsBranchProtection() [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 @@ public async Task GetsBranchProtectionWithRepositoryId() [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 @@ public async Task GetsBranchProtectionForOrgRepo() [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 @@ public class TheUpdateBranchProtectionMethod : GitHubClientTestBase [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 @@ public async Task UpdatesBranchProtection() [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 @@ public async Task UpdatesBranchProtectionWithRepositoryId() [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 @@ public async Task UpdatesBranchProtectionForOrgRepo() [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 @@ public class TheDeleteBranchProtectionMethod : GitHubClientTestBase [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 @@ public async Task DeletesBranchProtection() [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 @@ public async Task DeletesBranchProtectionWithRepositoryId() [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 @@ public async Task DeletesBranchProtectionForOrgRepo() [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 @@ public class TheGetRequiredStatusChecksMethod : GitHubClientTestBase [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 @@ public async Task GetsRequiredStatusChecks() [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 @@ public class TheUpdateRequiredStatusChecksMethod : GitHubClientTestBase [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 @@ public async Task UpdateRequiredStatusChecks() [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 @@ public class TheDeleteRequiredStatusChecksMethod : GitHubClientTestBase [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 @@ public async Task DeletesRequiredStatusChecks() [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 @@ public class TheGetAllRequiredStatusChecksContextsMethod : GitHubClientTestBase [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 @@ public async Task GetsRequiredStatusChecksContexts() [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 @@ public class TheUpdateRequiredStatusChecksContextsMethod : GitHubClientTestBase [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 @@ public async Task UpdateRequiredStatusChecksContexts() [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 @@ public class TheAddRequiredStatusChecksContextsMethod : GitHubClientTestBase [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 @@ public async Task AddsRequiredStatusChecksContexts() [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 @@ public class TheDeleteRequiredStatusChecksContextsMethod : GitHubClientTestBase [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 @@ public async Task DeletesRequiredStatusChecksContexts() [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 @@ public class TheGetReviewEnforcementMethod : GitHubClientTestBase [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 @@ public async Task GetsReviewEnforcement() [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 @@ public async Task GetsReviewEnforcementWithRepositoryId() [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 @@ public async Task GetsReviewEnforcementForOrgRepo() [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 @@ public class TheUpdateReviewEnforcementMethod : GitHubClientTestBase [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 @@ public async Task UpdatesReviewEnforcement() [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 @@ public async Task UpdatesReviewEnforcementWithRepositoryId() [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 @@ public async Task UpdatesReviewEnforcementForOrgRepo() [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 @@ public async Task UpdatesReviewEnforcementForOrgRepoWithRepositoryId() [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 @@ public async Task UpdatesReviewEnforcementForOrgRepoWithAdminOnly() [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 @@ public class TheRemoveReviewEnforcementMethod : GitHubClientTestBase [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 @@ public async Task RemovesReviewEnforcement() [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 @@ public async Task RemovesReviewEnforcementWithRepositoryId() [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 @@ public async Task RemovesReviewEnforcementForOrgRepo() [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 @@ public class TheGetAdminEnforcementMethod : GitHubClientTestBase [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 @@ public async Task GetsAdminEnforcement() [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 @@ public class TheAddAdminEnforcementMethod : GitHubClientTestBase [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 @@ public async Task AddsAdminEnforcement() [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 @@ public class TheRemoveAdminEnforcementMethod : GitHubClientTestBase [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 @@ public async Task RemovesAdminEnforcement() [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 @@ public async Task RemovesAdminEnforcementWithRepositoryId() 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 @@ public async Task GetsRequirProtectedBranchRestrictionsForOrgRepo() [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 @@ public class TheDeleteProtectedBranchRestrictionsMethod : GitHubClientTestBase [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 @@ public async Task DeletesRProtectedBranchRestrictionsForOrgRepo() [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 @@ public class TheGetAllProtectedBranchTeamRestrictionsMethod : GitHubClientTestBa [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 @@ public async Task GetsProtectedBranchTeamRestrictionsForOrgRepo() [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 @@ public class TheUpdateProtectedBranchTeamRestrictionsMethod : GitHubClientTestBa [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 @@ await _github.Organization.Team.AddRepository( [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 @@ public class TheAddProtectedBranchTeamRestrictionsMethod : GitHubClientTestBase [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 @@ await _github.Organization.Team.AddRepository( [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 @@ public class TheDeleteProtectedBranchTeamRestrictions : GitHubClientTestBase [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 @@ public async Task DeletesRProtectedBranchTeamRestrictionsForOrgRepo() [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 @@ public class TheGetAllProtectedBranchUserRestrictionsMethod : GitHubClientTestBa [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 @@ public async Task GetsProtectedBranchUserRestrictionsForOrgRepo() [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 @@ public class TheUpdateProtectedBranchUserRestrictionsMethod : GitHubClientTestBa [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 @@ public async Task UpdatesProtectedBranchUserRestrictionsForOrgRepo() [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 @@ public class TheAddProtectedBranchUserRestrictionsMethod : GitHubClientTestBase [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 @@ public async Task AddsProtectedBranchUserRestrictionsForOrgRepo() [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 @@ public class TheDeleteProtectedBranchUserRestrictions : GitHubClientTestBase [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 @@ public async Task DeletesProtectedBranchUserRestrictionsForOrgRepo() [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 aaccd9dfe1..0cc715e992 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs @@ -41,7 +41,7 @@ public async Task CanGetCommentWithRepositoryId() [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 async Task ReturnsDistinctResultsBasedOnStartWithRepositoryId() 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 async Task ReturnsDistinctResultsBasedOnStartForCommitWithRepositoryId() 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 TheCreateMethod : IDisposable 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 TheUpdateMethod() { _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 TheDeleteMethod() { _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 3332d56d64..e1d769f872 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs @@ -285,7 +285,7 @@ public async Task CanGetCommitWithRenamedFilesWithRepositoryId() [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 async Task CanGetSha1() [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 TestsWithNewRepository() _fixture = _github.Repository.Commit; - _context = _github.CreateRepositoryContext("source-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("source-repo").Result; } [IntegrationTest] @@ -319,7 +319,7 @@ public async Task CanCompareReferences() { 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 async Task CanCompareReferencesWithRepositoryId() { 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 async Task CanCompareReferencesOtherWayRound() { 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 async Task CanCompareReferencesOtherWayRoundWithRepositoryId() { 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 async Task ReturnsUrlsToResources() { 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 async Task ReturnsUrlsToResourcesWithRepositoryId() { 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 async Task CanCompareUsingSha() { 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 async Task CanCompareUsingShaWithRepositoryId() { 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 async Task GetSha1FromRepositoryWithRepositoryId() 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 099209d1b5..0501c092c7 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs @@ -73,7 +73,7 @@ public async Task GetsFileContent() 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 @@ public async Task GetsFileContentWithRepositoryId() 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 @@ public async Task GetsFileContentWholeRepo() 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 @@ public async Task GetsFileContentWholeRepoWithRepositoryId() 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 @@ public async Task GetsFileContent() 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 @@ public async Task GetsFileContentWithRepositoryId() 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 @@ public async Task GetsDirectoryContentWithTrailingSlash() } [IntegrationTest] - public async Task GetsContentNonMasterWithRootPath() + public async Task GetsContentNonMainWithRootPath() { var github = Helper.GetAuthenticatedClient(); @@ -256,7 +256,7 @@ public async Task GetsDirectoryContentWithRepositoryId() 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 @@ public async Task GetsFileContentWholeRepo() 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 @@ public async Task GetsFileContentWholeRepoWithRepositoryId() 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 @@ public async Task GetsDirectoryContentWholeRepo() 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 @@ public async Task GetsDirectoryContentWholeRepoWithRepositoryId() var contents = await github .Repository .Content - .GetAllContentsByRef(17881631, "master"); + .GetAllContentsByRef(17881631, "main"); Assert.NotEmpty(contents); } @@ -416,8 +416,8 @@ public async Task CrudTestWithNamedBranch() { 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 @@ public async Task CrudTestWithNamedBranchWithRepositoryId() { 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 @@ public async Task CrudTestWithNamedBranchWithExplicitBase64() { 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 @@ public async Task CrudTestWithNamedBranchWithRepositoryIdWithExplicitBase64() { 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 @@ public async Task GetsArchiveForReleaseBranchAsTarball() 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 @@ public async Task GetsArchiveForReleaseBranchAsTarballWithRepositoryId() 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 @@ public async Task GetsArchiveForReleaseBranchAsTarballWithTimeout() 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 @@ public async Task GetsArchiveForReleaseBranchAsTarballWithTimeoutWithRepositoryI 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 b9e29ae486..36ed67a14b 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryDeployKeysClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryDeployKeysClientTests.cs @@ -19,7 +19,7 @@ public RepositoryDeployKeysClientTests() 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 506da6f7e6..c64d6a02f2 100644 --- a/Octokit.Tests.Integration/Clients/SearchClientTests.cs +++ b/Octokit.Tests.Integration/Clients/SearchClientTests.cs @@ -640,7 +640,7 @@ public async Task SearchForExcludedHead() [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 7efca125c1..9809e7ce8e 100644 --- a/Octokit.Tests.Integration/Clients/StatisticsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/StatisticsClientTests.cs @@ -19,7 +19,7 @@ public StatisticsClientTests() [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 @@ public async Task CanCreateAndRetrieveContributors() [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 @@ public async Task CanCreateAndRetrieveEmptyContributorsWithRepositoryId() [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 @@ public async Task CanGetCommitActivityForTheLastYear() [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 @@ public async Task CanGetCommitActivityForTheLastYearWithRepositoryId() [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 @@ public async Task CanGetAdditionsAndDeletionsPerWeek() [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 @@ public async Task CanGetAdditionsAndDeletionsPerWeekWithRepositoryId() [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 @@ public async Task CanGetParticipationStatistics() [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 @@ public async Task CanGetParticipationStatisticsWithRepositoryId() [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 @@ public async Task CanGetPunchCardForRepository() [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 3fc83ee5f6..3aedbaf0b2 100644 --- a/Octokit.Tests.Integration/Clients/TagsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/TagsClientTests.cs @@ -17,7 +17,7 @@ public TheCreateMethod() 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 @@ public TheGetMethod() 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 ea7d2b7ed6..a069bb445c 100644 --- a/Octokit.Tests.Integration/Clients/TreeClientTests.cs +++ b/Octokit.Tests.Integration/Clients/TreeClientTests.cs @@ -17,7 +17,7 @@ public TreeClientTests() _fixture = _github.Git.Tree; - _context = _github.CreateRepositoryContext("public-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("public-repo").Result; } [IntegrationTest] @@ -73,7 +73,7 @@ public async Task CanCreateATreeWithRepositoryId() [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 async Task CanGetATree() [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 e49f186a19..beb067a0b5 100644 --- a/Octokit.Tests.Integration/Clients/WatchedClientTests.cs +++ b/Octokit.Tests.Integration/Clients/WatchedClientTests.cs @@ -299,7 +299,7 @@ public TheCheckWatchedMethod() _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 455b8a7de2..2bc13c74bf 100644 --- a/Octokit.Tests.Integration/Helper.cs +++ b/Octokit.Tests.Integration/Helper.cs @@ -247,6 +247,8 @@ public static string MakeNameWithTimestamp(string name) 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 a30f4e624a..941aeb9371 100644 --- a/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs +++ b/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs @@ -1,39 +1,97 @@ -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 await client.CreateUserRepositoryContext(x => x.AutoInit = true); + } + + /// + /// Creates a public repository with the repository name passed in and autoinit true + /// + internal static async Task CreateRepositoryContextWithAutoInit(this IGitHubClient client, string repositoryName) + { + return await client.CreateUserRepositoryContext(Helper.MakeNameWithTimestamp(repositoryName), x => x.AutoInit = true); + } + + internal static async Task CreateRepositoryContext(this IGitHubClient client, NewRepository newRepository) + { + var repo = await client.Repository.Create(newRepository); return new RepositoryContext(client.Connection, repo); } - internal static async Task CreateRepositoryContext(this IGitHubClient client, string repositoryName) + /// + /// Creates a public repository with the timestamped name "public-repo" and an optional function of parameters passed in + /// + /// + /// 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 repoName = Helper.MakeNameWithTimestamp(repositoryName); - var repo = await client.Repository.Create(new NewRepository(repoName) { AutoInit = true }); + var newRepository = new NewRepository(Helper.MakeNameWithTimestamp("public-repo")); + action?.Invoke(newRepository); + + var repo = await client.Repository.Create(newRepository); return new RepositoryContext(client.Connection, repo); } - internal static async Task CreateRepositoryContext(this IGitHubClient client, NewRepository newRepository) + /// + /// 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 organisationrepository with the timestamped name organisation-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) + 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 @@ internal static async Task CreateOrganizationRepositoryContex 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 01d1ae16fa..952b8fdf6a 100644 --- a/Octokit.Tests.Integration/Helpers/PaidAccountTestAttribute.cs +++ b/Octokit.Tests.Integration/Helpers/PaidAccountTestAttribute.cs @@ -23,6 +23,14 @@ public IEnumerable Discover(ITestFrameworkDiscoveryOptions disco 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 3a7f91133f..19eeddd612 100644 --- a/Octokit.Tests.Integration/Helpers/ReferenceExtensionsTests.cs +++ b/Octokit.Tests.Integration/Helpers/ReferenceExtensionsTests.cs @@ -13,11 +13,11 @@ public async Task CreateABranch() 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 3bfa7f4d02..49cbe1d88b 100644 --- a/Octokit.Tests.Integration/Helpers/RepositorySetupHelper.cs +++ b/Octokit.Tests.Integration/Helpers/RepositorySetupHelper.cs @@ -44,18 +44,18 @@ public static async Task CreateCommit(this IGitHubClient client, Reposit 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 @@ public static async Task CreateTheWorld(this IGitHubClient client, Re 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 0000000000..4de5e69847 --- /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 c7b95c492e..dad48855c9 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableCheckRunsClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableCheckRunsClientTests.cs @@ -29,7 +29,7 @@ public async Task CreatesCheckRun() 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 @@ public async Task CreatesCheckRunWithRepositoryId() 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 @@ public async Task UpdatesCheckRun() 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 @@ public async Task UpdatesCheckRunWithRepositoryId() 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 @@ public async Task GetsAllCheckRuns() 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 @@ public async Task GetsAllCheckRunsWithRepositoryId() 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 @@ public async Task GetsAllCheckRuns() 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 @@ public async Task GetsAllCheckRunsWithRepositoryId() 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 @@ public async Task GetsAllAnnotations() 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 @@ public async Task GetsAllAnnotationsWithRepositoryId() 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 68cc68df07..b9b44c28f8 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableCheckSuitesClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableCheckSuitesClientTests.cs @@ -28,7 +28,7 @@ public async Task GetsCheckSuite() 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 @@ public async Task GetsCheckSuiteWithRepositoryId() 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 @@ public async Task GetsAllCheckSuites() { 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 @@ public async Task GetsAllCheckSuitesWithRepositoryId() { 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 @@ public async Task CreatesCheckSuite() 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 @@ public async Task CreatesCheckSuiteWithRepositoryId() 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 @@ public async Task RerequestsCheckSuite() 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 @@ public async Task RerequestsCheckSuiteWithRepositoryId() 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);