public async Task GetsCheckRun() { 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 featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch var newCheckRun = new NewCheckRun("name", featureBranch.Object.Sha) { Status = CheckStatus.InProgress }; var created = await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryOwner, repoContext.RepositoryName, newCheckRun); // Get the check var checkRun = await _githubAppInstallation.Check.Run.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, created.Id); // Check result Assert.Equal(featureBranch.Object.Sha, checkRun.HeadSha); Assert.Equal("name", checkRun.Name); Assert.Equal(CheckStatus.InProgress, checkRun.Status); } }
public async Task CreatesCheckSuite() { using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Turn off auto creation of check suite for this repo var preference = new CheckSuitePreferences(new[] { new CheckSuitePreferenceAutoTrigger(Helper.GitHubAppId, false) }); 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 featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check suite for the feature branch var newCheckSuite = new NewCheckSuite(featureBranch.Object.Sha); var result = await _githubAppInstallation.Check.Suite.Create(repoContext.RepositoryOwner, repoContext.RepositoryName, newCheckSuite); // Check result Assert.NotNull(result); Assert.Equal(featureBranch.Object.Sha, result.HeadSha); } }
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 featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch var newCheckRun = new NewCheckRun("name", featureBranch.Object.Sha) { Status = CheckStatus.InProgress, Output = new NewCheckRunOutput("title", "summary") { Annotations = new[] { new NewCheckRunAnnotation("file.txt", 1, 1, CheckAnnotationLevel.Warning, "this is a warning") } } }; var created = await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryOwner, repoContext.RepositoryName, newCheckRun); // Get the annotations var annotations = await _githubAppInstallation.Check.Run.GetAllAnnotations(repoContext.RepositoryOwner, repoContext.RepositoryName, created.Id).ToList(); // Check result Assert.Equal(1, annotations.Count); Assert.Equal("this is a warning", annotations.First().Message); Assert.Equal(CheckAnnotationLevel.Warning, annotations.First().AnnotationLevel); } }
public async Task RequestsCheckSuite() { 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 result = await _githubAppInstallation.Check.Suite.Request(repoContext.RepositoryOwner, repoContext.RepositoryName, new CheckSuiteTriggerRequest(headCommit.Sha)); Assert.True(result); } }
public async Task CanQueueRepository() { var newRepository = new NewRepository(Helper.MakeNameWithTimestamp("public-repo")); using (var context = await _github.CreateRepositoryContext(newRepository)) { var observable = _github.Enterprise.SearchIndexing.Queue(EnterpriseHelper.UserName, context.RepositoryName); var response = await observable; Assert.NotNull(response); Assert.NotNull(response.Message); Assert.True(response.Message.All(m => m.Contains("was added to the indexing queue"))); } }
public TheMoveColumnMethod() { _github = new ObservableGitHubClient(Helper.GetAuthenticatedClient()); var repoName = Helper.MakeNameWithTimestamp("public-repo"); _context = _github.CreateRepositoryContext(new NewRepository(repoName)).Result; }
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 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); Assert.True(result); } }
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 checkSuites = await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha); Assert.NotEmpty(checkSuites.CheckSuites); foreach (var checkSuite in checkSuites.CheckSuites) { Assert.Equal(headCommit.Sha, checkSuite.HeadSha); } } }
public async Task UpdatesPreferences() { using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { var preference = new CheckSuitePreferences(new[] { new CheckSuitePreferenceAutoTrigger(Helper.GitHubAppId, false) }); var result = await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryOwner, repoContext.RepositoryName, preference); Assert.Equal(repoContext.RepositoryId, result.Repository.Id); Assert.Equal(Helper.GitHubAppId, result.Preferences.AutoTriggerChecks[0].AppId); Assert.Equal(false, result.Preferences.AutoTriggerChecks[0].Setting); } }