public async Task ShouldGetListOfWorkersWithPoolArgs() { CommandLineArgs.Add("-workerpool=SomePool"); Repository.WorkerPools.FindAll().Returns(new List <WorkerPoolResource> { new WorkerPoolResource { Name = "SomePool", Id = "WorkerPools-001" } }); var workerList = MakeWorkerList(1, new List <MachineModelStatus> { MachineModelStatus.Online }, new List <ReferenceCollection> { new ReferenceCollection("WorkerPools-001") }); Repository.Workers.FindMany(Arg.Any <Func <WorkerResource, bool> >()).Returns(workerList); await listWorkersCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain("Workers: 1"); LogLines.Should().Contain(string.Format(MachineLogFormat, workerList[0].Name, workerList[0].Status.ToString(), workerList[0].Id, "SomePool")); }
public void ShouldRemoveMachinesBelongingToMultiplePoolsInsteadOfDeleting() { CommandLineArgs.Add("-workerpool=SomePool"); CommandLineArgs.Add("-health-status=Unhealthy"); Repository.WorkerPools.FindByName("SomePool") .Returns( new WorkerPoolResource { Name = "SomePool", Id = "WorkerPools-001" } ); var workerList = MakeWorkerList(2, new List <ReferenceCollection> { new ReferenceCollection(new List <string> { "WorkerPools-001", "WorkerPools-002" }), new ReferenceCollection("WorkerPools-001") }); Repository.Workers.FindMany(Arg.Any <Func <WorkerResource, bool> >()).Returns(workerList); cleanPoolCommand.Execute(CommandLineArgs.ToArray()).GetAwaiter().GetResult(); LogLines.Should().Contain(string.Format("Found {0} machines in {1} with the status {2}", workerList.Count, "SomePool", MachineModelHealthStatus.Unhealthy.ToString())); LogLines.Should().Contain("Note: Some of these machines belong to multiple pools. Instead of being deleted, these machines will be removed from the SomePool pool."); LogLines.Should().Contain($"Removing {workerList[0].Name} {workerList[0].Status} (ID: {workerList[0].Id}) from SomePool"); Assert.That(workerList[0].WorkerPoolIds.Count, Is.EqualTo(1), "The machine should have been removed from the SomePool pool."); Repository.Workers.Received().Modify(workerList[0]); LogLines.Should().Contain(string.Format("Deleting {0} {1} (ID: {2})", workerList[1].Name, workerList[1].Status, workerList[1].Id)); Repository.Workers.Received().Delete(workerList[1]); }
public async Task ShouldGetListOfWorkerWithNoArgs() { Repository.WorkerPools.FindAll().Returns(new List <WorkerPoolResource> { new WorkerPoolResource { Name = "SomePool", Id = "WorkerPools-001" }, new WorkerPoolResource { Name = "SomeOtherPool", Id = "WorkerPools-002" } }); var workerList = MakeWorkerList(3, new List <MachineModelStatus> { MachineModelStatus.Online, MachineModelStatus.Offline, MachineModelStatus.Offline }, new List <ReferenceCollection> { new ReferenceCollection("WorkerPools-001"), new ReferenceCollection("WorkerPools-002"), new ReferenceCollection("WorkerPools-002") }); Repository.Workers.FindAll().Returns(workerList); await listWorkersCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain("Workers: 3"); LogLines.Should().Contain(string.Format(MachineLogFormat, workerList[0].Name, workerList[0].Status.ToString(), workerList[0].Id, "SomePool")); LogLines.Should().Contain(string.Format(MachineLogFormat, workerList[1].Name, workerList[1].Status.ToString(), workerList[1].Id, "SomeOtherPool")); LogLines.Should().Contain(string.Format(MachineLogFormat, workerList[2].Name, workerList[2].Status.ToString(), workerList[2].Id, "SomeOtherPool")); }
public async Task ShouldCreateNewChannel() { Repository.Client.RootDocument.Returns(new RootResource { Links = new LinkCollection().Add("Channels", "DOES_NOT_MATTER") }); var projectName = $"Project-{Guid.NewGuid()}"; var project = new ProjectResource() { Links = new LinkCollection().Add("Channels", "DOES_NOT_MATTER") }; Repository.Projects.FindByName(projectName).Returns(project); var lifecycleName = $"Lifecycle-{Guid.NewGuid()}"; Repository.Lifecycles.FindOne(Arg.Any <Func <LifecycleResource, bool> >()).Returns(new LifecycleResource()); Repository.Projects.GetChannels(Arg.Any <ProjectResource>()) .Returns(new ResourceCollection <ChannelResource>(Enumerable.Empty <ChannelResource>(), new LinkCollection())); var channelName = $"Channel-{Guid.NewGuid()}"; CommandLineArgs.Add($"--channel={channelName}"); CommandLineArgs.Add($"--project={projectName}"); CommandLineArgs.Add($"--lifecycle={lifecycleName}"); await createChannelCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain($"[Information] Channel {channelName} created"); }
public void ShouldCleanPool() { CommandLineArgs.Add("-workerpool=SomePool"); CommandLineArgs.Add("-health-status=Unhealthy"); Repository.WorkerPools.FindByName("SomePool") .Returns( new WorkerPoolResource { Name = "SomePool", Id = "WorkerPools-001" } ); var workerList = MakeWorkerList(2, new List <ReferenceCollection> { new ReferenceCollection("WorkerPools-001"), new ReferenceCollection("WorkerPools-001") }); Repository.Workers.FindMany(Arg.Any <Func <WorkerResource, bool> >()).Returns(workerList); cleanPoolCommand.Execute(CommandLineArgs.ToArray()).GetAwaiter().GetResult(); LogLines.Should().Contain(string.Format("Found {0} machines in {1} with the status {2}", workerList.Count, "SomePool", MachineModelHealthStatus.Unhealthy.ToString())); LogLines.Should().Contain(string.Format("Deleting {0} {1} (ID: {2})", workerList[0].Name, workerList[0].Status, workerList[0].Id)); Repository.Workers.Received().Delete(workerList[0]); LogLines.Should().Contain(string.Format("Deleting {0} {1} (ID: {2})", workerList[1].Name, workerList[1].Status, workerList[1].Id)); Repository.Workers.Received().Delete(workerList[1]); }
public async Task ShouldGetListOfMachinesWithNoArgs() { Repository.Environments.FindAll().Returns(new List <EnvironmentResource> { new EnvironmentResource { Name = "Development", Id = "Environments-001" } }); Repository.Machines.FindAll().Returns(new List <MachineResource> { new MachineResource { Name = "PC01234", Id = "Machines-001", Status = MachineModelStatus.Online, HealthStatus = MachineModelHealthStatus.Healthy, EnvironmentIds = new ReferenceCollection("Environments-001") }, new MachineResource { Name = "PC01466", Id = "Machines-002", Status = MachineModelStatus.Online, HealthStatus = MachineModelHealthStatus.Healthy, EnvironmentIds = new ReferenceCollection("Environments-001") } }); await listMachinesCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain("[Information] Machines: 2"); LogLines.Should().Contain(string.Format(MachineLogFormat, "PC01234", MachineModelStatus.Online.ToString(), "Machines-001", "Development")); LogLines.Should().Contain(string.Format(MachineLogFormat, "PC01466", MachineModelStatus.Online.ToString(), "Machines-002", "Development")); }
public async Task ShouldGetListOfMachinesWithEnvironmentArgs() { CommandLineArgs.Add("-environment=Development"); Repository.Environments.FindAll().Returns(new List <EnvironmentResource> { new EnvironmentResource { Name = "Development", Id = "Environments-001" } }); Repository.Machines.FindMany(Arg.Any <Func <MachineResource, bool> >()).Returns(new List <MachineResource> { new MachineResource { Name = "PC01234", Id = "Machines-001", Status = MachineModelStatus.Online, EnvironmentIds = new ReferenceCollection("Environments-001") } }); await listMachinesCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain("[Information] Machines: 1"); LogLines.Should().Contain(string.Format(MachineLogFormat, "PC01234", MachineModelStatus.Online.ToString(), "Machines-001", "Development")); LogLines.Should().NotContain(string.Format(MachineLogFormat, "PC01466", MachineModelStatus.Online.ToString(), "Machines-002", "Development")); LogLines.Should().NotContain(string.Format(MachineLogFormat, "PC01996", MachineModelStatus.Offline.ToString(), "Machines-003", "Development")); }
public async Task ShouldUpdateExistingChannel() { var channelName = SetupExistingChannel(); await createChannelCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain($"Channel {channelName} updated"); }
public async Task ShouldNotFailWhenTenantIsRemoved() { CommandLineArgs.Add("--project=ProjectA"); await listLatestDeploymentsCommands.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain(" - Tenant: tenant1"); LogLines.Should().Contain(" - Tenant: <Removed>"); }
public async Task ShouldGetListOfEnvironments() { SetupEnvironments(); await listEnvironmentsCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain("Environments: 2"); LogLines.Should().Contain(" - Dev (ID: devenvid)"); LogLines.Should().Contain(" - Prod (ID: prodenvid)"); }
public async Task ShouldGetListOfWorkerPools() { SetupPools(); await listWorkerPoolsCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain("WorkerPools: 2"); LogLines.Should().Contain(" - default (ID: defaultid)"); LogLines.Should().Contain(" - windows (ID: windowsid)"); }
public async Task ShouldGetListOfDeployments() { var argsWithNumber = new List <string>(CommandLineArgs) { "--number=1" }; await listDeploymentsCommands.Execute(argsWithNumber.ToArray()).ConfigureAwait(false); LogLines.Should().Contain(" - Project: ProjectA"); LogLines.Should().NotContain(" - Project: ProjectB"); }
public async Task ShouldGetListOfMachinesWithMachineHealthStatusArgs() { CommandLineArgs.Add("--health-status=HasWarnings"); (await Repository.LoadRootDocument()).Version = "3.5.0"; Repository.Environments.FindAll() .Returns(new List <EnvironmentResource> { new EnvironmentResource { Name = "Development", Id = "Environments-001" } }); Repository.Machines.FindAll() .Returns(new List <MachineResource> { new MachineResource { Name = "PC0123", Id = "Machines-001", Status = MachineModelStatus.Online, HealthStatus = MachineModelHealthStatus.Unavailable, EnvironmentIds = new ReferenceCollection("Environments-001") }, new MachineResource { Name = "PC01466", Id = "Machines-002", Status = MachineModelStatus.Online, HealthStatus = MachineModelHealthStatus.HasWarnings, EnvironmentIds = new ReferenceCollection("Environments-001") }, new MachineResource { Name = "PC01996", Id = "Machines-003", Status = MachineModelStatus.Offline, HealthStatus = MachineModelHealthStatus.Healthy, EnvironmentIds = new ReferenceCollection("Environments-001") } }); await listMachinesCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain("Machines: 1"); LogLines.Should() .Contain(string.Format(MachineLogFormat, "PC01466", MachineModelHealthStatus.HasWarnings.ToString(), "Machines-002", "Development")); }
public async Task ShouldDeleteOverrideForEnvironment() { CommandLineArgs.Add("-project=OctoFx"); CommandLineArgs.Add("-environment=Production"); project.AutoDeployReleaseOverrides.Add(new AutoDeployReleaseOverrideResource(environment.Id, release.Id)); await deleteAutoDeployOverrideCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain("Deleted auto deploy release override for the project OctoFx to the environment Production"); await Repository.Projects.ReceivedWithAnyArgs().Modify(null).ConfigureAwait(false); Assert.True(!savedProject.AutoDeployReleaseOverrides.Any()); }
public async Task DefaultOutput_CreateNewEnvironment() { var newEnv = Guid.NewGuid().ToString(); CommandLineArgs.Add($"--name={newEnv}"); Repository.Environments.FindByName(Arg.Any <string>()).Returns((EnvironmentResource)null); Repository.Environments.Create(Arg.Any <EnvironmentResource>()) .Returns(new EnvironmentResource { Id = Guid.NewGuid().ToString(), Name = newEnv }); await createEnvironmentCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain($"Creating environment: {newEnv}"); }
public async Task DefaultOutput_CreateNewWorkerPool() { var newPool = Guid.NewGuid().ToString(); CommandLineArgs.Add($"--name={newPool}"); Repository.WorkerPools.FindByName(Arg.Any <string>()).Returns((WorkerPoolResource)null); Repository.WorkerPools.Create(Arg.Any <WorkerPoolResource>()) .Returns(new WorkerPoolResource { Id = Guid.NewGuid().ToString(), Name = newPool }); await createWorkerPoolCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain($"Creating worker pool: {newPool}"); }
public async Task ShouldLogWarningIfUsingStatusOn34Repo() { CommandLineArgs.Add("--status=Online"); (await Repository.LoadRootDocument()).Version = "3.4.0"; Repository.Environments.FindAll() .Returns(new List <EnvironmentResource> { new EnvironmentResource { Name = "Development", Id = "Environments-001" } }); Repository.Machines.FindAll() .Returns(new List <MachineResource> { new MachineResource { Name = "PC0123", Id = "Machines-001", Status = MachineModelStatus.Online, HealthStatus = MachineModelHealthStatus.Unavailable, EnvironmentIds = new ReferenceCollection("Environments-001") }, new MachineResource { Name = "PC01466", Id = "Machines-002", Status = MachineModelStatus.Online, HealthStatus = MachineModelHealthStatus.HasWarnings, EnvironmentIds = new ReferenceCollection("Environments-001") }, new MachineResource { Name = "PC01996", Id = "Machines-003", Status = MachineModelStatus.Offline, HealthStatus = MachineModelHealthStatus.Healthy, EnvironmentIds = new ReferenceCollection("Environments-001") } }); await listMachinesCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain("The `--status` parameter will be deprecated in Octopus Deploy 4.0. You may want to execute this command with the `--health-status=` parameter instead."); LogLines.Should().Contain("Machines: 2"); }
public async Task ShouldGetListOfReleases() { Repository.Projects.FindByNames(Arg.Any <IEnumerable <string> >()).Returns(new List <ProjectResource> { new ProjectResource { Name = "ProjectA", Id = "projectaid" }, new ProjectResource { Name = "ProjectB", Id = "projectbid" } }); Repository.Releases.FindMany(Arg.Any <Func <ReleaseResource, bool> >()).Returns(new List <ReleaseResource> { new ReleaseResource { ProjectId = "projectaid", Version = "1.0", Assembled = DateTimeOffset.MinValue, ReleaseNotes = "Release Notes 1" }, new ReleaseResource { ProjectId = "projectaid", Version = "2.0", Assembled = DateTimeOffset.MaxValue, ReleaseNotes = "Release Notes 2" } }); CommandLineArgs.Add("--project=ProjectA"); await listReleasesCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain(string.Format("Releases: {0}", 2)); LogLines.Should().Contain(string.Format(" - Project: {0}", "ProjectA")); LogLines.Should().Contain(string.Format(" {0}", "Version: 1.0")); LogLines.Should().Contain(string.Format(" {0}", "Assembled: " + DateTimeOffset.MinValue)); LogLines.Should().Contain(string.Format(" {0}", "Package Versions: ")); LogLines.Should().Contain(string.Format(" {0}", "Release Notes: Release Notes 1")); LogLines.Should().Contain(string.Format(" {0}", "Version: 2.0")); LogLines.Should().Contain(string.Format(" {0}", "Assembled: " + DateTimeOffset.MaxValue)); LogLines.Should().Contain(string.Format(" {0}", "Package Versions: ")); LogLines.Should().Contain(string.Format(" {0}", "Release Notes: Release Notes 2")); }
public async Task ShouldGetListOfProjects() { Repository.Projects.FindAll().Returns(new List <ProjectResource> { new ProjectResource { Name = "ProjectA", Id = "projectaid" }, new ProjectResource { Name = "ProjectB", Id = "projectbid" } }); await listProjectsCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain("[Information] Projects: 2"); LogLines.Should().Contain("[Information] - ProjectA (ID: projectaid)"); LogLines.Should().Contain("[Information] - ProjectB (ID: projectbid)"); }
public async Task ShouldAddOverrideForEnvironmentAndRelease() { CommandLineArgs.Add("-project=OctoFx"); CommandLineArgs.Add("-environment=Production"); CommandLineArgs.Add("-version=1.2.0"); await createAutoDeployOverrideCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain("Auto deploy will deploy version 1.2.0 of the project OctoFx to the environment Production"); await Repository.Projects.ReceivedWithAnyArgs().Modify(null).ConfigureAwait(false); var autoDeployOverride = savedProject.AutoDeployReleaseOverrides.Single(); Assert.AreEqual(project.Id, savedProject.Id); Assert.AreEqual(release.Id, autoDeployOverride.ReleaseId); Assert.AreEqual(null, autoDeployOverride.TenantId); Assert.AreEqual(environment.Id, autoDeployOverride.EnvironmentId); }
public void ShouldRemoveMachinesBelongingToMultipleEnvironmentsInsteadOfDeleting() { CommandLineArgs.Add("-environment=Development"); CommandLineArgs.Add("-status=Offline"); Repository.Environments.FindByName("Development") .Returns( new EnvironmentResource { Name = "Development", Id = "Environments-001" } ); var machineList = new List <MachineResource> { new MachineResource { Name = "PC01466", Id = "Machines-002", Status = MachineModelStatus.Offline, EnvironmentIds = new ReferenceCollection(new[] { "Environments-001", "Environments-002" }) }, new MachineResource { Name = "PC01996", Id = "Machines-003", Status = MachineModelStatus.Offline, EnvironmentIds = new ReferenceCollection("Environments-001") } }; Repository.Machines.FindMany(Arg.Any <Func <MachineResource, bool> >()).Returns(machineList); listMachinesCommand.Execute(CommandLineArgs.ToArray()).GetAwaiter().GetResult(); LogLines.Should().Contain(string.Format("Found {0} machines in {1} with the status {2}", machineList.Count, "Development", MachineModelStatus.Offline.ToString())); LogLines.Should().Contain("Note: Some of these machines belong to multiple environments. Instead of being deleted, these machines will be removed from the Development environment."); LogLines.Should().Contain($"Removing {machineList[0].Name} {machineList[0].Status} (ID: {machineList[0].Id}) from Development"); Assert.That(machineList[0].EnvironmentIds.Count, Is.EqualTo(1), "The machine should have been removed from the Development environment."); Repository.Machines.Received().Modify(machineList[0]); LogLines.Should().Contain(string.Format("Deleting {0} {1} (ID: {2})", machineList[1].Name, machineList[1].Status, machineList[1].Id)); Repository.Machines.Received().Delete(machineList[1]); }
public void ShouldCleanEnvironmentWithEnvironmentAndStatusArgs() { CommandLineArgs.Add("-environment=Development"); CommandLineArgs.Add("-status=Offline"); Repository.Environments.FindByName("Development") .Returns( new EnvironmentResource { Name = "Development", Id = "Environments-001" } ); var machineList = new List <MachineResource> { new MachineResource { Name = "PC01466", Id = "Machines-002", Status = MachineModelStatus.Offline, EnvironmentIds = new ReferenceCollection("Environments-001") }, new MachineResource { Name = "PC01996", Id = "Machines-003", Status = MachineModelStatus.Offline, EnvironmentIds = new ReferenceCollection("Environments-001") } }; Repository.Machines.FindMany(Arg.Any <Func <MachineResource, bool> >()).Returns(machineList); listMachinesCommand.Execute(CommandLineArgs.ToArray()).GetAwaiter().GetResult(); LogLines.Should().Contain(string.Format("Found {0} machines in {1} with the status {2}", machineList.Count, "Development", MachineModelStatus.Offline.ToString())); LogLines.Should().Contain(string.Format("Deleting {0} {1} (ID: {2})", machineList[0].Name, machineList[0].Status, machineList[0].Id)); Repository.Machines.Received().Delete(machineList[0]); LogLines.Should().Contain(string.Format("Deleting {0} {1} (ID: {2})", machineList[1].Name, machineList[1].Status, machineList[1].Id)); Repository.Machines.Received().Delete(machineList[1]); }
public async Task ShouldGetListOfEnvironments() { Repository.Environments.FindAll().Returns(new List <EnvironmentResource> { new EnvironmentResource() { Name = "Dev", Id = "devenvid" }, new EnvironmentResource() { Name = "Prod", Id = "prodenvid" } }); await listEnvironmentsCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain("[Information] Environments: 2"); LogLines.Should().Contain("[Information] - Dev (ID: devenvid)"); LogLines.Should().Contain("[Information] - Prod (ID: prodenvid)"); }
public async Task DefaultOutput_ShouldCreateNewProject() { Repository.ProjectGroups.Create(Arg.Any <ProjectGroupResource>()) .Returns(new ProjectGroupResource { Id = Guid.NewGuid().ToString(), Name = groupName }); Repository.Lifecycles.FindOne(Arg.Any <Func <LifecycleResource, bool> >()) .Returns(new LifecycleResource { Id = Guid.NewGuid().ToString(), Name = lifecycleName }); Repository.Projects.Create(Arg.Any <ProjectResource>()) .Returns(new ProjectResource { Id = projectId, Name = projectName }); await createProjectCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain($"Creating project: {projectName}"); LogLines.Should().Contain($"Project created. ID: {projectId}"); LogLines.Should().Contain("Project group does not exist, it will be created"); }
public async Task ShouldSupportStateFilters() { CommandLineArgs.Add("--health-status=Healthy"); CommandLineArgs.Add("--calamari-outdated=false"); CommandLineArgs.Add("--tentacle-outdated=true"); CommandLineArgs.Add("--disabled=true"); Repository.Client.RootDocument.Version = "3.4.0"; Repository.Environments.FindAll().Returns(new List <EnvironmentResource> { new EnvironmentResource { Name = "Development", Id = "Environments-001" } }); Repository.Machines.FindAll().Returns(new List <MachineResource> { new MachineResource { Name = "PC0123", Id = "Machines-001", HealthStatus = MachineModelHealthStatus.Unavailable, EnvironmentIds = new ReferenceCollection("Environments-001") }, new MachineResource { Name = "PC01466", Id = "Machines-002", HealthStatus = MachineModelHealthStatus.Healthy, IsDisabled = true, HasLatestCalamari = true, Endpoint = new ListeningTentacleEndpointResource() { TentacleVersionDetails = new TentacleDetailsResource { UpgradeSuggested = true } }, EnvironmentIds = new ReferenceCollection("Environments-001") }, new MachineResource { Name = "PC01467", Id = "Machines-003", HealthStatus = MachineModelHealthStatus.Healthy, IsDisabled = true, HasLatestCalamari = true, Endpoint = new ListeningTentacleEndpointResource() { TentacleVersionDetails = new TentacleDetailsResource { UpgradeSuggested = false } }, EnvironmentIds = new ReferenceCollection("Environments-001") }, new MachineResource { Name = "PC01468", Id = "Machines-004", HealthStatus = MachineModelHealthStatus.Healthy, IsDisabled = true, EnvironmentIds = new ReferenceCollection("Environments-001"), HasLatestCalamari = false }, new MachineResource { Name = "PC01999", Id = "Machines-005", HealthStatus = MachineModelHealthStatus.Healthy, IsDisabled = false, EnvironmentIds = new ReferenceCollection("Environments-001") } }); await listMachinesCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain("[Information] Machines: 1"); LogLines.Should().Contain(string.Format(MachineLogFormat, "PC01466", "Healthy - Disabled", "Machines-002", "Development")); }
public async Task ShouldSupportStateFilters() { CommandLineArgs.Add("--health-status=Healthy"); CommandLineArgs.Add("--calamari-outdated=false"); CommandLineArgs.Add("--tentacle-outdated=true"); CommandLineArgs.Add("--disabled=true"); (await Repository.LoadRootDocument()).Version = "3.4.0"; Repository.WorkerPools.FindAll() .Returns(new List <WorkerPoolResource> { new WorkerPoolResource { Name = "SomePool", Id = "WorkerPools-001" } }); Repository.Workers.FindAll() .Returns(new List <WorkerResource> { new WorkerResource { Name = "PC0123", Id = "Machines-001", HealthStatus = MachineModelHealthStatus.Unavailable, WorkerPoolIds = new ReferenceCollection("WorkerPools-001") }, new WorkerResource { Name = "PC01466", Id = "Machines-002", HealthStatus = MachineModelHealthStatus.Healthy, IsDisabled = true, HasLatestCalamari = true, Endpoint = new ListeningTentacleEndpointResource { TentacleVersionDetails = new TentacleDetailsResource { UpgradeSuggested = true } }, WorkerPoolIds = new ReferenceCollection("WorkerPools-001") }, new WorkerResource { Name = "PC01467", Id = "Machines-003", HealthStatus = MachineModelHealthStatus.Healthy, IsDisabled = true, HasLatestCalamari = true, Endpoint = new ListeningTentacleEndpointResource { TentacleVersionDetails = new TentacleDetailsResource { UpgradeSuggested = false } }, WorkerPoolIds = new ReferenceCollection("WorkerPools-001") }, new WorkerResource { Name = "PC01468", Id = "Machines-004", HealthStatus = MachineModelHealthStatus.Healthy, IsDisabled = true, WorkerPoolIds = new ReferenceCollection("WorkerPools-001"), HasLatestCalamari = false }, new WorkerResource { Name = "PC01999", Id = "Machines-005", HealthStatus = MachineModelHealthStatus.Healthy, IsDisabled = false, WorkerPoolIds = new ReferenceCollection("WorkerPools-001") } }); await listWorkersCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain("Workers: 1"); LogLines.Should() .Contain(string.Format(MachineLogFormat, "PC01466", "Healthy - Disabled", "Machines-002", "SomePool")); }
public async Task ShouldGetListOfDeployments() { var deploymentResources = new ResourceCollection <DeploymentResource>( new List <DeploymentResource> { new DeploymentResource { Name = "", Id = "deploymentid1", ProjectId = "projectaid", EnvironmentId = "environmentid1" }, new DeploymentResource { Name = "", Id = "deploymentid2", ProjectId = "projectbid", EnvironmentId = "environmentid2" }, }, new LinkCollection()); Repository.FeaturesConfiguration.GetFeaturesConfiguration() .ReturnsForAnyArgs(new FeaturesConfigurationResource { }); Repository.Deployments .When( x => x.Paginate(Arg.Any <string[]>(), Arg.Any <string[]>(), Arg.Any <string[]>(), Arg.Any <Func <ResourceCollection <DeploymentResource>, bool> >())) .Do(r => r.Arg <Func <ResourceCollection <DeploymentResource>, bool> >()(deploymentResources)); Repository.Projects.FindAll() .Returns(Task.FromResult( new List <ProjectResource> { new ProjectResource { Name = "ProjectA", Id = "projectaid" }, new ProjectResource { Name = "ProjectB", Id = "projectbid" }, })); Repository.Environments.FindAll() .Returns(Task.FromResult( new List <EnvironmentResource> { new EnvironmentResource { Name = "EnvA", Id = "environmentid1" }, new EnvironmentResource { Name = "EnvB", Id = "environmentid2" } })); Repository.Tenants.FindAll() .Returns(Task.FromResult(new List <TenantResource>())); Repository.Releases.Get(Arg.Any <string>()).ReturnsForAnyArgs(new ReleaseResource { Version = "0.0.1" }); var argsWithNumber = new List <string>(CommandLineArgs) { "--number=1" }; await listDeploymentsCommands.Execute(argsWithNumber.ToArray()).ConfigureAwait(false); LogLines.Should().Contain("[Information] - Project: ProjectA"); LogLines.Should().NotContain("[Information] - Project: ProjectB"); }