* Make `async:true` the default for `invoke` calls (#3750) * Switch away from native grpc impl. (#3728) * Remove usage of the 'deasync' library from @pulumi/pulumi. (#3752) * Only retry as long as we get unavailable back. Anything else continues. (#3769) * Handle all errors for now. (#3781) * Do not assume --yes was present when using pulumi in non-interactive mode (#3793) * Upgrade all paths for sdk and pkg to v2 * Backport C# invoke classes and other recent gen changes (#4288) Adjust C# generation * Replace IDeployment with a sealed class (#4318) Replace IDeployment with a sealed class * .NET: default to args subtype rather than Args.Empty (#4320) * Adding system namespace for Dotnet code gen This is required for using Obsolute attributes for deprecations ``` Iam/InstanceProfile.cs(142,10): error CS0246: The type or namespace name 'ObsoleteAttribute' could not be found (are you missing a using directive or an assembly reference?) [/Users/stack72/code/go/src/github.com/pulumi/pulumi-aws/sdk/dotnet/Pulumi.Aws.csproj] Iam/InstanceProfile.cs(142,10): error CS0246: The type or namespace name 'Obsolete' could not be found (are you missing a using directive or an assembly reference?) [/Users/stack72/code/go/src/github.com/pulumi/pulumi-aws/sdk/dotnet/Pulumi.Aws.csproj] ``` * Fix the nullability of config type properties in C# codegen (#4379)
89 lines
3.5 KiB
Go
Executable file
89 lines
3.5 KiB
Go
Executable file
// Copyright 2018, Pulumi Corporation.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
package tests
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/pulumi/pulumi/pkg/v2/testing/integration"
|
|
ptesting "github.com/pulumi/pulumi/sdk/v2/go/common/testing"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
// deleteIfNotFailed deletes the files in the testing environment if the testcase has
|
|
// not failed. (Otherwise they are left to aid debugging.)
|
|
func deleteIfNotFailed(e *ptesting.Environment) {
|
|
if !e.T.Failed() {
|
|
e.DeleteEnvironment()
|
|
}
|
|
}
|
|
|
|
// assertHasNoHistory runs `pulumi history` and confirms an error that the stack has not
|
|
// ever been updated.
|
|
func assertHasNoHistory(e *ptesting.Environment) {
|
|
// NOTE: pulumi returns with exit code 0 in this scenario.
|
|
out, err := e.RunCommand("pulumi", "history")
|
|
assert.Equal(e.T, "", err)
|
|
assert.Equal(e.T, "Stack has never been updated\n", out)
|
|
}
|
|
func TestHistoryCommand(t *testing.T) {
|
|
// We fail if no stack is selected.
|
|
t.Run("NoStackSelected", func(t *testing.T) {
|
|
e := ptesting.NewEnvironment(t)
|
|
defer deleteIfNotFailed(e)
|
|
integration.CreateBasicPulumiRepo(e)
|
|
e.RunCommand("pulumi", "login", "--cloud-url", e.LocalURL())
|
|
out, err := e.RunCommandExpectError("pulumi", "history")
|
|
assert.Equal(t, "", out)
|
|
assert.Contains(t, err, "error: no stack selected")
|
|
})
|
|
|
|
// We don't display any history for a stack that has never been updated.
|
|
t.Run("NoUpdates", func(t *testing.T) {
|
|
e := ptesting.NewEnvironment(t)
|
|
defer deleteIfNotFailed(e)
|
|
integration.CreateBasicPulumiRepo(e)
|
|
e.RunCommand("pulumi", "login", "--cloud-url", e.LocalURL())
|
|
e.RunCommand("pulumi", "stack", "init", "no-updates-test")
|
|
assertHasNoHistory(e)
|
|
})
|
|
|
|
// The "history" command uses the currently selected stack.
|
|
t.Run("CurrentlySelectedStack", func(t *testing.T) {
|
|
e := ptesting.NewEnvironment(t)
|
|
defer deleteIfNotFailed(e)
|
|
integration.CreateBasicPulumiRepo(e)
|
|
e.ImportDirectory("integration/stack_dependencies")
|
|
e.RunCommand("pulumi", "login", "--cloud-url", e.LocalURL())
|
|
e.ImportDirectory("integration/stack_outputs")
|
|
e.RunCommand("pulumi", "stack", "init", "stack-without-updates")
|
|
e.RunCommand("pulumi", "stack", "init", "history-test")
|
|
e.RunCommand("yarn", "install")
|
|
e.RunCommand("yarn", "link", "@pulumi/pulumi")
|
|
// Update the history-test stack.
|
|
e.RunCommand("pulumi", "up", "--non-interactive", "--yes", "--skip-preview", "-m", "this is an updated stack")
|
|
// Confirm we see the update message in thie history output.
|
|
out, err := e.RunCommand("pulumi", "history")
|
|
assert.Equal(t, "", err)
|
|
assert.Contains(t, out, "this is an updated stack")
|
|
// Change stack and confirm the history command honors the selected stack.
|
|
e.RunCommand("pulumi", "stack", "select", "stack-without-updates")
|
|
assertHasNoHistory(e)
|
|
// Change stack back, and confirm still has history.
|
|
e.RunCommand("pulumi", "stack", "select", "history-test")
|
|
out, err = e.RunCommand("pulumi", "history")
|
|
assert.Equal(t, "", err)
|
|
assert.Contains(t, out, "this is an updated stack")
|
|
})
|
|
}
|