public TheDownloadStatusMethod()
        {
            _githubEnterprise             = EnterpriseHelper.GetAuthenticatedClient();
            _preReceiveEnvironmentsClient = _githubEnterprise.Enterprise.PreReceiveEnvironment;

            var newPreReceiveEnvironment = new NewPreReceiveEnvironment(Helper.MakeNameWithTimestamp("pre-receive"), "https://example.com/foo.zip");

            _preReceiveEnvironment = _preReceiveEnvironmentsClient.Create(newPreReceiveEnvironment).Result;
        }
        public TheTriggerDownloadMethod()
        {
            _githubEnterprise             = EnterpriseHelper.GetAuthenticatedClient();
            _preReceiveEnvironmentsClient = _githubEnterprise.Enterprise.PreReceiveEnvironment;

            var newPreReceiveEnvironment = new NewPreReceiveEnvironment(Helper.MakeNameWithTimestamp("pre-receive"), "https://example.com/foo.zip");

            _preReceiveEnvironment = _preReceiveEnvironmentsClient.Create(newPreReceiveEnvironment).Result;
            EnterpriseHelper.WaitForPreReceiveEnvironmentToComplete(_githubEnterprise.Connection, _preReceiveEnvironment);
        }
예제 #3
0
        public TheEditMethod()
        {
            _githubEnterprise             = new ObservableGitHubClient(EnterpriseHelper.GetAuthenticatedClient());
            _preReceiveEnvironmentsClient = _githubEnterprise.Enterprise.PreReceiveEnvironment;

            var newPreReceiveEnvironment = new NewPreReceiveEnvironment(Helper.MakeNameWithTimestamp("pre-receive"), "https://example.com/foo.zip");

            _preReceiveEnvironment = _preReceiveEnvironmentsClient.Create(newPreReceiveEnvironment).Wait();
            EnterpriseHelper.WaitForPreReceiveEnvironmentToComplete(_githubEnterprise.Connection, _preReceiveEnvironment);
        }
            public void RequestsTheCorrectUrl()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableEnterprisePreReceiveEnvironmentsClient(gitHubClient);
                var data         = new NewPreReceiveEnvironment("name", "url");

                client.Create(data);

                gitHubClient.Enterprise.PreReceiveEnvironment.Received(1).Create(data);
            }
        public async Task CanDeletePreReceiveEnvironment()
        {
            var newPreReceiveEnvironment = new NewPreReceiveEnvironment(Helper.MakeNameWithTimestamp("pre-receive"), "https://example.com/foo.zip");
            var preReceiveEnvironment    = await _preReceiveEnvironmentsClient.Create(newPreReceiveEnvironment);

            EnterpriseHelper.WaitForPreReceiveEnvironmentToComplete(_githubEnterprise.Connection, preReceiveEnvironment);

            await _preReceiveEnvironmentsClient.Delete(preReceiveEnvironment.Id);

            await Assert.ThrowsAsync <NotFoundException>(async() => await _preReceiveEnvironmentsClient.Get(preReceiveEnvironment.Id));
        }
        public TheGetMethod()
        {
            _githubEnterprise             = EnterpriseHelper.GetAuthenticatedClient();
            _preReceiveEnvironmentsClient = _githubEnterprise.Enterprise.PreReceiveEnvironment;

            _preReceiveEnvironmentName = Helper.MakeNameWithTimestamp("pre-receive");
            _preReceiveEnvironmentUrl  = "https://example.com/foo.zip";
            var newPreReceiveEnvironment = new NewPreReceiveEnvironment(_preReceiveEnvironmentName, _preReceiveEnvironmentUrl);

            _preReceiveEnvironment = _preReceiveEnvironmentsClient.Create(newPreReceiveEnvironment).Result;
        }
        public TheGetAllMethod()
        {
            _githubEnterprise             = EnterpriseHelper.GetAuthenticatedClient();
            _preReceiveEnvironmentsClient = _githubEnterprise.Enterprise.PreReceiveEnvironment;

            _preReceiveEnvironments = new List <PreReceiveEnvironment>();
            for (var count = 0; count < 5; count++)
            {
                var newPreReceiveEnvironment = new NewPreReceiveEnvironment(Helper.MakeNameWithTimestamp("pre-receive"), "https://example.com/foo.zip");
                _preReceiveEnvironments.Add(_preReceiveEnvironmentsClient.Create(newPreReceiveEnvironment).Result);
            }
        }
            public async Task RequestsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new EnterprisePreReceiveEnvironmentsClient(connection);
                var data       = new NewPreReceiveEnvironment("name", "url");

                await client.Create(data);

                connection.Received().Post <PreReceiveEnvironment>(Arg.Is <Uri>(u => u.ToString() == "admin/pre-receive-environments"),
                                                                   data,
                                                                   "application/vnd.github.eye-scream-preview+json");
            }
        public async Task CanCreatePreReceiveEnvironment()
        {
            PreReceiveEnvironment preReceiveEnvironment = null;

            try
            {
                var newPreReceiveEnvironment = new NewPreReceiveEnvironment(Helper.MakeNameWithTimestamp("pre-receive"), "https://example.com/foo.zip");

                preReceiveEnvironment = await _preReceiveEnvironmentsClient.Create(newPreReceiveEnvironment);

                Assert.NotNull(preReceiveEnvironment);
                Assert.Equal(newPreReceiveEnvironment.Name, preReceiveEnvironment.Name);
                Assert.Equal(newPreReceiveEnvironment.ImageUrl, preReceiveEnvironment.ImageUrl);
            }
            finally
            {
                //Cleanup
                EnterpriseHelper.DeletePreReceiveEnvironment(_githubEnterprise.Connection, preReceiveEnvironment);
            }
        }
        public async Task CannotCreateWithSameName()
        {
            var newPreReceiveEnvironment = new NewPreReceiveEnvironment("default", "https://example.com/foo.zip");

            await Assert.ThrowsAsync <ApiValidationException>(() => _preReceiveEnvironmentsClient.Create(newPreReceiveEnvironment));
        }
예제 #11
0
        /// <summary>
        /// Creates a new <see cref="PreReceiveEnvironment"/>.
        /// </summary>
        /// <remarks>
        /// See the <a href="https://developer.github.com/v3/enterprise-admin/pre_receive_environments/#create-a-pre-receive-environment">API documentation</a> for more information.
        /// </remarks>
        /// <param name="newPreReceiveEnvironment">A description of the pre-receive environment to create</param>
        /// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
        public IObservable <PreReceiveEnvironment> Create(NewPreReceiveEnvironment newPreReceiveEnvironment)
        {
            Ensure.ArgumentNotNull(newPreReceiveEnvironment, nameof(newPreReceiveEnvironment));

            return(_client.Create(newPreReceiveEnvironment).ToObservable());
        }