Пример #1
0
 private static ReleaseTemplatePackage GetReleaseTemplatePackage()
 {
     return(new ReleaseTemplatePackage
     {
         StepName = TestHelpers.GetId("step")
     });
 }
Пример #2
0
 public static DeploymentStepResource GetStep()
 {
     return(new DeploymentStepResource
     {
         Id = TestHelpers.GetId("deploymentstep"),
         Name = TestHelpers.GetId("deploymentstepName"),
     });
 }
Пример #3
0
 public static DeploymentActionResource GetAction()
 {
     return(new DeploymentActionResource
     {
         IsDisabled = false,
         Id = TestHelpers.GetId("action"),
         Name = TestHelpers.GetId("actionname")
     });
 }
Пример #4
0
        public void Setup()
        {
            // setup data objects
            channelVersionRules = new List <ChannelVersionRuleResource>();
            projectResource     = new ProjectResource
            {
                DeploymentProcessId = TestHelpers.GetId("deploymentprocess"),
                Id = TestHelpers.GetId("project")
            };
            deploymentProcessResource = new DeploymentProcessResource
            {
                ProjectId = projectResource.Id,
                Id        = projectResource.DeploymentProcessId
            };

            releaseTemplateResource = new ReleaseTemplateResource
            {
                DeploymentProcessId = projectResource.DeploymentProcessId,
                Packages            = new List <ReleaseTemplatePackage>(),
                Id = TestHelpers.GetId("releaseTemplate")
            };
            channelResource = new ChannelResource
            {
                IsDefault = true,
                Id        = TestHelpers.GetId("channel"),
                ProjectId = projectResource.Id,
                Rules     = channelVersionRules,
                Name      = TestHelpers.GetId("channelname")
            };
            feedResource = new FeedResource
            {
                Links = new LinkCollection {
                    { "SearchTemplate", TestHelpers.GetId("searchUri") }
                }
            };

            // setup mocks
            logger            = Substitute.For <ILogger>();
            versionResolver   = Substitute.For <IPackageVersionResolver>();
            versionRuleTester = Substitute.For <IChannelVersionRuleTester>();

            deploymentProcessRepository = Substitute.For <IDeploymentProcessRepository>();
            deploymentProcessRepository.Get(projectResource.DeploymentProcessId)
            .Returns(Task.FromResult(deploymentProcessResource));
            deploymentProcessRepository
            .GetTemplate(Arg.Is <DeploymentProcessResource>(deploymentProcessResource),
                         Arg.Is <ChannelResource>(channelResource)).Returns(Task.FromResult(releaseTemplateResource));
            versionRuleTester
            .Test(Arg.Any <IOctopusAsyncRepository>(), Arg.Any <ChannelVersionRuleResource>(), Arg.Any <string>())
            .Returns(Task.FromResult(channelVersionRuleTestResult));

            releaseRepository = Substitute.For <IReleaseRepository>();
            feedRepository    = Substitute.For <IFeedRepository>();
            feedRepository.Get(Arg.Any <string>()).Returns(feedResource);

            repository = Substitute.For <IOctopusAsyncRepository>();
            repository.DeploymentProcesses.Returns(deploymentProcessRepository);
            repository.Releases.Returns(releaseRepository);
            repository.Feeds.Returns(feedRepository);
            repository.Client
            .Get <List <PackageResource> >(Arg.Any <string>(), Arg.Any <IDictionary <string, object> >()).Returns(packages);

            builder = new ReleasePlanBuilder(logger, versionResolver, versionRuleTester);
        }
Пример #5
0
 public static ReleaseTemplatePackage WithPackage(this ReleaseTemplatePackage releaseTemplatePackage)
 {
     releaseTemplatePackage.PackageId = TestHelpers.GetId("package");
     releaseTemplatePackage.FeedId    = TestHelpers.GetId("feed");
     return(releaseTemplatePackage);
 }
Пример #6
0
 public static DeploymentActionResource WithPackage(this DeploymentActionResource action)
 {
     action.Properties["Octopus.Action.Package.PackageId"] = TestHelpers.GetId("package");
     return(action);
 }
Пример #7
0
        public void SingleEnabledScriptStepScopedToDifferentChannel_ShouldNotBeAViablePlan()
        {
            // arrange
            var deploymentStepResource = ResourceBuilderHelpers.GetStep();

            deploymentStepResource.Actions.Add(ResourceBuilderHelpers.GetAction().WithChannel(TestHelpers.GetId("differentchannel")));
            deploymentProcessResource.Steps.Add(deploymentStepResource);

            // act
            var plan = ExecuteBuild();

            // assert
            plan.IsViableReleasePlan().Should().BeFalse();
        }