Пример #1
0
            public async Task CreatesCheckSuiteWithRepositoryId()
            {
                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.RepositoryId, preference);

                    // 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 suite for the feature branch
                    var newCheckSuite = new NewCheckSuite(featureBranch.Object.Sha);
                    var result        = await _githubAppInstallation.Check.Suite.Create(repoContext.RepositoryId, newCheckSuite);

                    // Check result
                    Assert.NotNull(result);
                    Assert.Equal(featureBranch.Object.Sha, result.HeadSha);
                }
            }
            public async Task EnsuresNonEmptyArguments()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableCheckSuitesClient(gitHubClient);

                var preferences = new CheckSuitePreferences(new[] { new CheckSuitePreferenceAutoTrigger(123, true) });

                Assert.Throws <ArgumentException>(() => client.UpdatePreferences("", "repo", preferences));
                Assert.Throws <ArgumentException>(() => client.UpdatePreferences("fake", "", preferences));
            }
            public async Task RequestsCorrectUrlWithRepositoryId()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableCheckSuitesClient(gitHubClient);

                var preferences = new CheckSuitePreferences(new[] { new CheckSuitePreferenceAutoTrigger(123, true) });

                client.UpdatePreferences(1, preferences);

                gitHubClient.Check.Suite.Received().UpdatePreferences(1, preferences);
            }
Пример #4
0
            public async Task EnsuresNonEmptyArguments()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new CheckSuitesClient(connection);

                var preferences = new CheckSuitePreferences(new[] { new CheckSuitePreferenceAutoTrigger(123, true) });

                await Assert.ThrowsAsync <ArgumentException>(() => client.UpdatePreferences("", "repo", preferences));

                await Assert.ThrowsAsync <ArgumentException>(() => client.UpdatePreferences("fake", "", preferences));
            }
Пример #5
0
            public async Task RequestsCorrectUrlWithRepositoryId()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new CheckSuitesClient(connection);

                var preferences = new CheckSuitePreferences(new[] { new CheckSuitePreferenceAutoTrigger(123, true) });

                await client.UpdatePreferences(1, preferences);

                connection.Received().Patch <CheckSuitePreferencesResponse>(
                    Arg.Is <Uri>(u => u.ToString() == "repositories/1/check-suites/preferences"),
                    preferences,
                    "application/vnd.github.antiope-preview+json");
            }
Пример #6
0
            public async Task UpdatesPreferencesWithRepositoryId()
            {
                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.RepositoryId, 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);
                }
            }
Пример #7
0
        /// <summary>
        /// Updates Check Suites prefrences on a repository, such as disabling automatic creation when code is pushed
        /// </summary>
        /// <remarks>
        /// See the <a href="https://developer.github.com/v3/checks/suites/#set-preferences-for-check-suites-on-a-repository">Check Suites API documentation</a> for more information.
        /// </remarks>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="preferences">The check suite preferences</param>
        public IObservable <CheckSuitePreferencesResponse> UpdatePreferences(long repositoryId, CheckSuitePreferences preferences)
        {
            Ensure.ArgumentNotNull(preferences, nameof(preferences));

            return(_client.UpdatePreferences(repositoryId, preferences).ToObservable());
        }
Пример #8
0
        /// <summary>
        /// Updates Check Suites prefrences on a repository, such as disabling automatic creation when code is pushed
        /// </summary>
        /// <remarks>
        /// See the <a href="https://developer.github.com/v3/checks/suites/#set-preferences-for-check-suites-on-a-repository">Check Suites 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="preferences">The check suite preferences</param>
        public IObservable <CheckSuitePreferencesResponse> UpdatePreferences(string owner, string name, CheckSuitePreferences preferences)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
            Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
            Ensure.ArgumentNotNull(preferences, nameof(preferences));

            return(_client.UpdatePreferences(owner, name, preferences).ToObservable());
        }