[automation/dotnet] - Isolate project and stack names, defer stack removal for tests (#6584)
This commit is contained in:
parent
a2f995d2bb
commit
dd53f58acb
|
@ -112,7 +112,7 @@ namespace Pulumi.Automation.Tests
|
|||
[Fact]
|
||||
public async Task CreateSelectRemoveStack()
|
||||
{
|
||||
var projectSettings = new ProjectSettings("node_test", ProjectRuntimeName.NodeJS);
|
||||
var projectSettings = new ProjectSettings("create_select_remove_stack_test", ProjectRuntimeName.NodeJS);
|
||||
using var workspace = await LocalWorkspace.CreateAsync(new LocalWorkspaceOptions
|
||||
{
|
||||
ProjectSettings = projectSettings,
|
||||
|
@ -122,7 +122,7 @@ namespace Pulumi.Automation.Tests
|
|||
}
|
||||
});
|
||||
|
||||
var stackName = $"int_test{GetTestSuffix()}";
|
||||
var stackName = $"create_select_remove_stack_test-{GetTestSuffix()}";
|
||||
|
||||
var stacks = await workspace.ListStacksAsync();
|
||||
if (stacks.Any(s => s.Name == stackName))
|
||||
|
@ -147,7 +147,7 @@ namespace Pulumi.Automation.Tests
|
|||
[Fact]
|
||||
public async Task ManipulateConfig()
|
||||
{
|
||||
var projectName = "node_test";
|
||||
var projectName = "manipulate_config_test";
|
||||
var projectSettings = new ProjectSettings(projectName, ProjectRuntimeName.NodeJS);
|
||||
|
||||
using var workspace = await LocalWorkspace.CreateAsync(new LocalWorkspaceOptions
|
||||
|
@ -159,7 +159,7 @@ namespace Pulumi.Automation.Tests
|
|||
}
|
||||
});
|
||||
|
||||
var stackName = $"int_test{GetTestSuffix()}";
|
||||
var stackName = $"manipulate_config_test-{GetTestSuffix()}";
|
||||
var stack = await WorkspaceStack.CreateAsync(stackName, workspace);
|
||||
|
||||
var config = new Dictionary<string, ConfigValue>()
|
||||
|
@ -171,6 +171,8 @@ namespace Pulumi.Automation.Tests
|
|||
var plainKey = NormalizeConfigKey("plain", projectName);
|
||||
var secretKey = NormalizeConfigKey("secret", projectName);
|
||||
|
||||
try
|
||||
{
|
||||
await Assert.ThrowsAsync<CommandException>(
|
||||
() => stack.GetConfigValueAsync(plainKey));
|
||||
|
||||
|
@ -193,9 +195,12 @@ namespace Pulumi.Automation.Tests
|
|||
await stack.SetConfigValueAsync("foo", new ConfigValue("bar"));
|
||||
values = await stack.GetConfigAsync();
|
||||
Assert.Equal(2, values.Count);
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
await workspace.RemoveStackAsync(stackName);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ListStackAndCurrentlySelected()
|
||||
|
@ -241,7 +246,7 @@ namespace Pulumi.Automation.Tests
|
|||
[Fact]
|
||||
public async Task CheckStackStatus()
|
||||
{
|
||||
var projectSettings = new ProjectSettings("node_test", ProjectRuntimeName.NodeJS);
|
||||
var projectSettings = new ProjectSettings("check_stack_status_test", ProjectRuntimeName.NodeJS);
|
||||
using var workspace = await LocalWorkspace.CreateAsync(new LocalWorkspaceOptions
|
||||
{
|
||||
ProjectSettings = projectSettings,
|
||||
|
@ -251,7 +256,7 @@ namespace Pulumi.Automation.Tests
|
|||
}
|
||||
});
|
||||
|
||||
var stackName = $"int_test{GetTestSuffix()}";
|
||||
var stackName = $"check_stack_status_test-{GetTestSuffix()}";
|
||||
var stack = await WorkspaceStack.CreateAsync(stackName, workspace);
|
||||
try
|
||||
{
|
||||
|
@ -284,6 +289,8 @@ namespace Pulumi.Automation.Tests
|
|||
["bar"] = new ConfigValue("abc"),
|
||||
["buzz"] = new ConfigValue("secret", isSecret: true),
|
||||
};
|
||||
try
|
||||
{
|
||||
await stack.SetConfigAsync(config);
|
||||
|
||||
// pulumi up
|
||||
|
@ -320,9 +327,12 @@ namespace Pulumi.Automation.Tests
|
|||
var destroyResult = await stack.DestroyAsync();
|
||||
Assert.Equal(UpdateKind.Destroy, destroyResult.Summary.Kind);
|
||||
Assert.Equal(UpdateState.Succeeded, destroyResult.Summary.Result);
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
await stack.Workspace.RemoveStackAsync(stackName);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task StackLifecycleInlineProgram()
|
||||
|
@ -353,6 +363,8 @@ namespace Pulumi.Automation.Tests
|
|||
["bar"] = new ConfigValue("abc"),
|
||||
["buzz"] = new ConfigValue("secret", isSecret: true),
|
||||
};
|
||||
try
|
||||
{
|
||||
await stack.SetConfigAsync(config);
|
||||
|
||||
// pulumi up
|
||||
|
@ -389,9 +401,12 @@ namespace Pulumi.Automation.Tests
|
|||
var destroyResult = await stack.DestroyAsync();
|
||||
Assert.Equal(UpdateKind.Destroy, destroyResult.Summary.Kind);
|
||||
Assert.Equal(UpdateState.Succeeded, destroyResult.Summary.Result);
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
await stack.Workspace.RemoveStackAsync(stackName);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact(Skip="Breaking builds")]
|
||||
public async Task StackReferenceDestroyDiscardsWithTwoInlinePrograms()
|
||||
|
@ -510,6 +525,8 @@ namespace Pulumi.Automation.Tests
|
|||
}
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
var outputCalled = false;
|
||||
|
||||
// pulumi preview
|
||||
|
@ -536,6 +553,11 @@ namespace Pulumi.Automation.Tests
|
|||
Assert.False(string.IsNullOrEmpty(destroyResult.StandardOutput));
|
||||
Assert.True(outputCalled);
|
||||
}
|
||||
finally
|
||||
{
|
||||
await stack.Workspace.RemoveStackAsync(stack.Name);
|
||||
}
|
||||
}
|
||||
|
||||
private class ValidStack : Stack
|
||||
{
|
||||
|
@ -577,6 +599,8 @@ namespace Pulumi.Automation.Tests
|
|||
["bar"] = new ConfigValue("abc"),
|
||||
["buzz"] = new ConfigValue("secret", isSecret: true),
|
||||
};
|
||||
try
|
||||
{
|
||||
await stack.SetConfigAsync(config);
|
||||
|
||||
// pulumi up
|
||||
|
@ -613,9 +637,12 @@ namespace Pulumi.Automation.Tests
|
|||
var destroyResult = await stack.DestroyAsync();
|
||||
Assert.Equal(UpdateKind.Destroy, destroyResult.Summary.Kind);
|
||||
Assert.Equal(UpdateState.Succeeded, destroyResult.Summary.Result);
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
await stack.Workspace.RemoveStackAsync(stackName);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task InlineProgramExceptionPropagatesToCaller()
|
||||
|
|
|
@ -541,6 +541,9 @@ namespace Pulumi.Automation
|
|||
public override async Task<ImmutableList<StackSummary>> ListStacksAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
var result = await this.RunCommandAsync(new[] { "stack", "ls", "--json" }, cancellationToken).ConfigureAwait(false);
|
||||
if (string.IsNullOrWhiteSpace(result.StandardOutput))
|
||||
return ImmutableList<StackSummary>.Empty;
|
||||
|
||||
var stacks = this._serializer.DeserializeJson<List<StackSummary>>(result.StandardOutput);
|
||||
return stacks.ToImmutableList();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue