Пример #1
0
        private void when_create_a_task()
        {
            before = () =>
            {
                _snapshotStep         = new SnapshotStep();
                _expectedTaskResource = new TaskResource {
                    Id = "Task01"
                };
                var deploymentResource = new DeploymentResource {
                    TaskId = _expectedTaskResource.Id
                };
                A.CallTo(() => _deployments.Create(A <DeploymentResource> ._)).Returns(deploymentResource);
                A.CallTo(() => _tasks.Get(A <string> ._)).Returns(_expectedTaskResource);
            };

            act = () => { _actualTaskResource = _factory.Create(_snapshotStep, "Environment01"); };

            it["should return a task"] = () => { _actualTaskResource.should_be(_expectedTaskResource); };

            it["should create a deployment"] = () =>
            {
                A.CallTo(() => _deployments.Create(A <DeploymentResource> .That.Matches(x =>
                                                                                        x.ReleaseId == _snapshotStep.ReleaseId &&
                                                                                        x.ProjectId == _snapshotStep.ProjectId &&
                                                                                        x.EnvironmentId == "Environment01"
                                                                                        ))).MustHaveHappened();
            };
        }
Пример #2
0
        /// <inheritdoc/>
        public async Task <DeploymentEntity> CreateAsync(DeploymentModel deployment)
        {
            DeploymentEntity deploymentEntity = new DeploymentEntity();

            deploymentEntity.PopulateBaseProperties(_org, _app, _httpContext);
            deploymentEntity.TagName         = deployment.TagName;
            deploymentEntity.EnvironmentName = deployment.Environment.Name;

            ReleaseEntity release = await _releaseRepository.GetSucceededReleaseFromDb(deploymentEntity.Org, deploymentEntity.App, deploymentEntity.TagName);

            await _applicationInformationService
            .UpdateApplicationInformationAsync(_org, _app, release.TargetCommitish, deployment.Environment);

            Build queuedBuild = await QueueDeploymentBuild(release, deploymentEntity, deployment.Environment.Hostname);

            deploymentEntity.Build = new BuildEntity
            {
                Id      = queuedBuild.Id.ToString(),
                Status  = queuedBuild.Status,
                Started = queuedBuild.StartTime
            };

            return(await _deploymentRepository.Create(deploymentEntity));
        }