2021-08-24 23:29:27 +02:00
|
|
|
package tests
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"runtime"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/pulumi/pulumi/pkg/v3/testing/integration"
|
|
|
|
ptesting "github.com/pulumi/pulumi/sdk/v3/go/common/testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestAboutCommands(t *testing.T) {
|
2021-08-25 08:59:51 +02:00
|
|
|
stackName := "pulumi-about"
|
2021-08-25 09:34:14 +02:00
|
|
|
|
|
|
|
// pulumi about --json
|
|
|
|
|
|
|
|
// Note: Order matters. We rely on there being no current stack to garentee
|
|
|
|
// warnings will be generated.
|
|
|
|
t.Run("jsonAbout", func(t *testing.T) {
|
2021-08-24 23:29:27 +02:00
|
|
|
e := ptesting.NewEnvironment(t)
|
|
|
|
defer func() {
|
|
|
|
if !t.Failed() {
|
|
|
|
e.DeleteEnvironment()
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
integration.CreateBasicPulumiRepo(e)
|
|
|
|
e.SetBackend(e.LocalURL())
|
2021-08-25 03:15:38 +02:00
|
|
|
e.RunCommand("yarn", "install")
|
|
|
|
e.RunCommand("yarn", "link", "@pulumi/pulumi")
|
2021-08-24 23:29:27 +02:00
|
|
|
_, currentStack := integration.GetStacks(e)
|
2021-08-25 09:34:14 +02:00
|
|
|
stdout, stderr := e.RunCommand("pulumi", "about", "--json")
|
|
|
|
assert.Contains(t, stderr, "warning")
|
|
|
|
var res interface{}
|
|
|
|
assert.Nil(t, json.Unmarshal([]byte(stdout), &res), "Should be valid json")
|
2021-08-24 23:29:27 +02:00
|
|
|
assert.Contains(t, stdout, runtime.Version())
|
|
|
|
assert.Contains(t, stdout, runtime.Compiler)
|
|
|
|
assert.Containsf(t, stdout, "Current Stack: %s", *currentStack)
|
|
|
|
})
|
2021-08-25 09:34:14 +02:00
|
|
|
|
|
|
|
// pulumi about
|
|
|
|
t.Run("plainAbout", func(t *testing.T) {
|
2021-08-24 23:29:27 +02:00
|
|
|
e := ptesting.NewEnvironment(t)
|
|
|
|
defer func() {
|
|
|
|
if !t.Failed() {
|
|
|
|
e.DeleteEnvironment()
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
integration.CreateBasicPulumiRepo(e)
|
|
|
|
e.SetBackend(e.LocalURL())
|
2021-08-25 03:15:38 +02:00
|
|
|
e.RunCommand("yarn", "install")
|
|
|
|
e.RunCommand("yarn", "link", "@pulumi/pulumi")
|
2021-08-25 09:34:14 +02:00
|
|
|
e.RunCommand("pulumi", "stack", "init", stackName)
|
|
|
|
e.RunCommand("pulumi", "up", "--non-interactive", "--yes", "--skip-preview")
|
2021-08-25 00:59:06 +02:00
|
|
|
_, currentStack := integration.GetStacks(e)
|
2021-08-25 09:34:14 +02:00
|
|
|
stdout, stderr := e.RunCommand("pulumi", "about")
|
|
|
|
assert.Empty(t, stderr, "There should be no errors")
|
2021-08-24 23:29:27 +02:00
|
|
|
assert.Contains(t, stdout, runtime.Version())
|
|
|
|
assert.Contains(t, stdout, runtime.Compiler)
|
|
|
|
assert.Containsf(t, stdout, "Current Stack: %s", *currentStack)
|
|
|
|
})
|
|
|
|
}
|