public async Task RequestsCorrectUrlWithRequestWithApiOptions() { var connection = Substitute.For <IConnection>(); var gitHubClient = new GitHubClient(connection); var client = new ObservableCheckRunsClient(gitHubClient); var request = new CheckRunRequest { CheckName = "build", Filter = CheckRunCompletedAtFilter.Latest, Status = CheckStatusFilter.InProgress }; var options = new ApiOptions { PageSize = 1 }; client.GetAllForCheckSuite("fake", "repo", 1, request, options); connection.Received().Get <List <CheckRunsResponse> >( Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/check-suites/1/check-runs"), Arg.Is <Dictionary <string, string> >(x => x.Count == 4 && x["per_page"] == "1" && x["check_name"] == "build" && x["status"] == "in_progress" && x["filter"] == "latest"), "application/vnd.github.antiope-preview+json"); }
public async Task EnsuresNonEmptyArguments() { var gitHubClient = Substitute.For <IGitHubClient>(); var client = new ObservableCheckRunsClient(gitHubClient); var request = new CheckRunRequest { CheckName = "build" }; Assert.Throws <ArgumentException>(() => client.GetAllForReference("", "repo", "ref")); Assert.Throws <ArgumentException>(() => client.GetAllForReference("fake", "", "ref")); Assert.Throws <ArgumentException>(() => client.GetAllForReference("fake", "repo", "")); Assert.Throws <ArgumentException>(() => client.GetAllForReference("", "repo", "ref", request)); Assert.Throws <ArgumentException>(() => client.GetAllForReference("fake", "", "ref", request)); Assert.Throws <ArgumentException>(() => client.GetAllForReference("fake", "repo", "", request)); Assert.Throws <ArgumentException>(() => client.GetAllForReference("", "repo", "ref", request, ApiOptions.None)); Assert.Throws <ArgumentException>(() => client.GetAllForReference("fake", "", "ref", request, ApiOptions.None)); Assert.Throws <ArgumentException>(() => client.GetAllForReference("fake", "repo", "", request, ApiOptions.None)); Assert.Throws <ArgumentException>(() => client.GetAllForReference(1, "")); Assert.Throws <ArgumentException>(() => client.GetAllForReference(1, "", request)); Assert.Throws <ArgumentException>(() => client.GetAllForReference(1, "", request, ApiOptions.None)); }
/// <inheritdoc/> protected override async Task <object> CallGitHubApi(DialogContext dc, Octokit.GitHubClient gitHubClient, CancellationToken cancellationToken = default(CancellationToken)) { if (Owner != null && Name != null && Reference != null && CheckRunRequest != null && Options != null) { var ownerValue = Owner.GetValue(dc.State); var nameValue = Name.GetValue(dc.State); var referenceValue = Reference.GetValue(dc.State); var checkRunRequestValue = CheckRunRequest.GetValue(dc.State); var optionsValue = Options.GetValue(dc.State); return(await gitHubClient.Check.Run.GetAllForReference(ownerValue, nameValue, referenceValue, checkRunRequestValue, optionsValue).ConfigureAwait(false)); } if (Owner != null && Name != null && Reference != null && CheckRunRequest != null) { var ownerValue = Owner.GetValue(dc.State); var nameValue = Name.GetValue(dc.State); var referenceValue = Reference.GetValue(dc.State); var checkRunRequestValue = CheckRunRequest.GetValue(dc.State); return(await gitHubClient.Check.Run.GetAllForReference(ownerValue, nameValue, referenceValue, checkRunRequestValue).ConfigureAwait(false)); } if (RepositoryId != null && Reference != null && CheckRunRequest != null && Options != null) { var repositoryIdValue = RepositoryId.GetValue(dc.State); var referenceValue = Reference.GetValue(dc.State); var checkRunRequestValue = CheckRunRequest.GetValue(dc.State); var optionsValue = Options.GetValue(dc.State); return(await gitHubClient.Check.Run.GetAllForReference((Int64)repositoryIdValue, referenceValue, checkRunRequestValue, optionsValue).ConfigureAwait(false)); } if (Owner != null && Name != null && Reference != null) { var ownerValue = Owner.GetValue(dc.State); var nameValue = Name.GetValue(dc.State); var referenceValue = Reference.GetValue(dc.State); return(await gitHubClient.Check.Run.GetAllForReference(ownerValue, nameValue, referenceValue).ConfigureAwait(false)); } if (RepositoryId != null && Reference != null && CheckRunRequest != null) { var repositoryIdValue = RepositoryId.GetValue(dc.State); var referenceValue = Reference.GetValue(dc.State); var checkRunRequestValue = CheckRunRequest.GetValue(dc.State); return(await gitHubClient.Check.Run.GetAllForReference((Int64)repositoryIdValue, referenceValue, checkRunRequestValue).ConfigureAwait(false)); } if (RepositoryId != null && Reference != null) { var repositoryIdValue = RepositoryId.GetValue(dc.State); var referenceValue = Reference.GetValue(dc.State); return(await gitHubClient.Check.Run.GetAllForReference((Int64)repositoryIdValue, referenceValue).ConfigureAwait(false)); } throw new ArgumentNullException("Required [reference] arguments missing for GitHubClient.Check.Run.GetAllForReference"); }
public async Task EnsuresNonNullArguments() { var connection = Substitute.For <IApiConnection>(); var client = new CheckRunsClient(connection); var request = new CheckRunRequest { CheckName = "build" }; await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForReference(null, "repo", "ref")); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForReference("fake", null, "ref")); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForReference("fake", "repo", null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForReference(null, "repo", "ref", request)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForReference("fake", null, "ref", request)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForReference("fake", "repo", null, request)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForReference("fake", "repo", "ref", null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForReference(null, "repo", "ref", request, ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForReference("fake", null, "ref", request, ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForReference("fake", "repo", null, request, ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForReference("fake", "repo", "ref", null, ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForReference("fake", "repo", "ref", request, null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForReference(1, null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForReference(1, null, request)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForReference(1, "ref", null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForReference(1, null, request, ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForReference(1, "ref", null, ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForReference(1, "ref", request, null)); }
public async Task RequestsCorrectUrlWithRequestWithRepositoryId() { var connection = Substitute.For <IConnection>(); var gitHubClient = new GitHubClient(connection); var client = new ObservableCheckRunsClient(gitHubClient); var request = new CheckRunRequest { CheckName = "build", Filter = CheckRunCompletedAtFilter.Latest, Status = CheckStatusFilter.InProgress }; client.GetAllForReference(1, "ref", request); connection.Received().Get <List <CheckRunsResponse> >( Arg.Is <Uri>(u => u.ToString() == "repositories/1/commits/ref/check-runs"), Arg.Is <Dictionary <string, string> >(x => x.Count == 3 && x["check_name"] == "build" && x["status"] == "in_progress" && x["filter"] == "latest"), "application/vnd.github.antiope-preview+json"); }
public async Task EnsuresNonEmptyArguments() { var connection = Substitute.For <IApiConnection>(); var client = new CheckRunsClient(connection); var request = new CheckRunRequest { CheckName = "build" }; await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForCheckSuite("", "repo", 1)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForCheckSuite("fake", "", 1)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForCheckSuite("", "repo", 1, request)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForCheckSuite("fake", "", 1, request)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForCheckSuite("", "repo", 1, request, ApiOptions.None)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForCheckSuite("fake", "", 1, request, ApiOptions.None)); }
public async Task RequestsCorrectUrlWithRequestWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new CheckRunsClient(connection); var request = new CheckRunRequest { CheckName = "build", Filter = CheckRunCompletedAtFilter.Latest, Status = CheckStatusFilter.InProgress }; await client.GetAllForCheckSuite(1, 1, request); connection.Received().GetAll <CheckRunsResponse>( Arg.Is <Uri>(u => u.ToString() == "repositories/1/check-suites/1/check-runs"), Arg.Is <Dictionary <string, string> >(x => x.Count == 3 && x["check_name"] == "build" && x["status"] == "in_progress" && x["filter"] == "latest"), "application/vnd.github.antiope-preview+json", Args.ApiOptions); }
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 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 request = new CheckRunRequest { CheckName = "name", Status = CheckStatusFilter.InProgress }; var checkRuns = await _githubAppInstallation.Check.Run.GetAllForCheckSuite(repoContext.RepositoryOwner, repoContext.RepositoryName, created.CheckSuite.Id, request); // Check result Assert.NotEmpty(checkRuns.CheckRuns); foreach (var checkRun in checkRuns.CheckRuns) { Assert.Equal(featureBranch.Object.Sha, checkRun.HeadSha); Assert.Equal("name", checkRun.Name); Assert.Equal(CheckStatus.InProgress, checkRun.Status); } } }
public async Task RequestsCorrectUrlWithRequestWithApiOptions() { var connection = Substitute.For <IApiConnection>(); var client = new CheckRunsClient(connection); var request = new CheckRunRequest { CheckName = "build", Filter = CheckRunCompletedAtFilter.Latest, Status = CheckStatusFilter.InProgress }; var options = new ApiOptions { PageSize = 1 }; await client.GetAllForReference("fake", "repo", "ref", request, options); connection.Received().GetAll <CheckRunsResponse>( Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/commits/ref/check-runs"), Arg.Is <Dictionary <string, string> >(x => x.Count == 3 && x["check_name"] == "build" && x["status"] == "in_progress" && x["filter"] == "latest"), "application/vnd.github.antiope-preview+json", options); }
/// <summary> /// Lists check runs for a check suite using its Id /// </summary> /// <remarks> /// See the <a href="https://developer.github.com/v3/checks/runs/#list-check-runs-in-a-check-suite">Check Runs API documentation</a> for more information. /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="checkSuiteId">The Id of the check suite</param> /// <param name="checkRunRequest">Details to filter the request, such as by check name</param> /// <param name="options">Options to change the API response</param> public IObservable <CheckRunsResponse> GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options) { Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); Ensure.ArgumentNotNull(options, nameof(options)); return(_connection.GetAndFlattenAllPages <CheckRunsResponse>(ApiUrls.CheckRunsForCheckSuite(repositoryId, checkSuiteId), checkRunRequest.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options)); }
/// <summary> /// Lists check runs for a check suite using its Id /// </summary> /// <remarks> /// See the <a href="https://developer.github.com/v3/checks/runs/#list-check-runs-in-a-check-suite">Check Runs API documentation</a> for more information. /// </remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="checkSuiteId">The Id of the check suite</param> /// <param name="checkRunRequest">Details to filter the request, such as by check name</param> /// <param name="options">Options to change the API response</param> public IObservable <CheckRunsResponse> GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); Ensure.ArgumentNotNull(options, nameof(options)); return(_connection.GetAndFlattenAllPages <CheckRunsResponse>(ApiUrls.CheckRunsForCheckSuite(owner, name, checkSuiteId), checkRunRequest.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options)); }
/// <summary> /// Lists check runs for a check suite using its Id /// </summary> /// <remarks> /// See the <a href="https://developer.github.com/v3/checks/runs/#list-check-runs-in-a-check-suite">Check Runs API documentation</a> for more information. /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="checkSuiteId">The Id of the check suite</param> /// <param name="checkRunRequest">Details to filter the request, such as by check name</param> public IObservable <CheckRunsResponse> GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest) { Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); return(GetAllForCheckSuite(repositoryId, checkSuiteId, checkRunRequest, ApiOptions.None)); }
/// <summary> /// Lists check runs for a check suite using its Id /// </summary> /// <remarks> /// See the <a href="https://developer.github.com/v3/checks/runs/#list-check-runs-in-a-check-suite">Check Runs API documentation</a> for more information. /// </remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="checkSuiteId">The Id of the check suite</param> /// <param name="checkRunRequest">Details to filter the request, such as by check name</param> public IObservable <CheckRunsResponse> GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); return(GetAllForCheckSuite(owner, name, checkSuiteId, checkRunRequest, ApiOptions.None)); }
/// <summary> /// Lists check runs for a commit ref. The ref can be a SHA, branch name, or a tag name /// </summary> /// <remarks> /// See the <a href="https://developer.github.com/v3/checks/runs/#list-check-runs-for-a-specific-ref">Check Runs API documentation</a> for more information. /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="reference">The commit reference (can be a SHA, branch name, or a tag name)</param> /// <param name="checkRunRequest">Details to filter the request, such as by check name</param> public IObservable <CheckRunsResponse> GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest) { Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); return(GetAllForReference(repositoryId, reference, checkRunRequest, ApiOptions.None)); }
/// <summary> /// Lists check runs for a commit ref. The ref can be a SHA, branch name, or a tag name /// </summary> /// <remarks> /// See the <a href="https://developer.github.com/v3/checks/runs/#list-check-runs-for-a-specific-ref">Check Runs API documentation</a> for more information. /// </remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="reference">The commit reference (can be a SHA, branch name, or a tag name)</param> /// <param name="checkRunRequest">Details to filter the request, such as by check name</param> public IObservable <CheckRunsResponse> GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); return(GetAllForReference(owner, name, reference, checkRunRequest, ApiOptions.None)); }