Update tests and add integration test
This commit is contained in:
parent
567ded6894
commit
d49a594093
|
@ -16,7 +16,6 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
@ -59,7 +58,7 @@ func TestBackend(t *testing.T) {
|
|||
backend, err := getHostAbout()
|
||||
assert.Nil(t, err, "We should be able to get stats here")
|
||||
display := backend.String()
|
||||
assert.Contains(stats.Platform, display, "This should be a valid regex")
|
||||
assert.Contains(stats.PlatformVersion, display, "This should be a valid regex")
|
||||
assert.Contains(stats.KernelArch, display, "This should be a valid regex")
|
||||
assert.Contains(t, display, stats.Platform)
|
||||
assert.Contains(t, display, stats.PlatformVersion)
|
||||
assert.Contains(t, display, stats.KernelArch)
|
||||
}
|
||||
|
|
9
tests/README.md
Normal file
9
tests/README.md
Normal file
|
@ -0,0 +1,9 @@
|
|||
# Integration Tests
|
||||
|
||||
This module provides integration tests for the Pulumi CLI.
|
||||
|
||||
The tests can be run via:
|
||||
|
||||
``` sh
|
||||
make test_all
|
||||
```
|
52
tests/about_test.go
Normal file
52
tests/about_test.go
Normal file
|
@ -0,0 +1,52 @@
|
|||
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) {
|
||||
// pulumi about
|
||||
t.Run("plainAbout", func(t *testing.T) {
|
||||
e := ptesting.NewEnvironment(t)
|
||||
defer func() {
|
||||
if !t.Failed() {
|
||||
e.DeleteEnvironment()
|
||||
}
|
||||
}()
|
||||
|
||||
integration.CreateBasicPulumiRepo(e)
|
||||
e.SetBackend(e.LocalURL())
|
||||
_, currentStack := integration.GetStacks(e)
|
||||
stdout, stderr := e.RunCommand("pulumi", "about")
|
||||
assert.Empty(t, stderr, "We shouldn't print anything to stderr")
|
||||
assert.Contains(t, stdout, runtime.Version())
|
||||
assert.Contains(t, stdout, runtime.Compiler)
|
||||
assert.Containsf(t, stdout, "Current Stack: %s", *currentStack)
|
||||
})
|
||||
// pulumi about --json
|
||||
t.Run("jsonAbout", func(t *testing.T) {
|
||||
e := ptesting.NewEnvironment(t)
|
||||
defer func() {
|
||||
if !t.Failed() {
|
||||
e.DeleteEnvironment()
|
||||
}
|
||||
}()
|
||||
|
||||
integration.CreateBasicPulumiRepo(e)
|
||||
e.SetBackend(e.LocalURL())
|
||||
stacks, currentStack := integration.GetStacks(e)
|
||||
stdout, stderr := e.RunCommand("pulumi", "about", "--json")
|
||||
assert.Empty(t, stderr, "We shouldn't print anything to stderr")
|
||||
var res interface{}
|
||||
assert.Nil(t, json.Unmarshal([]byte(stdout), &res), "Should be valid json")
|
||||
assert.Contains(t, stdout, runtime.Version())
|
||||
assert.Contains(t, stdout, runtime.Compiler)
|
||||
assert.Containsf(t, stdout, "Current Stack: %s", *currentStack)
|
||||
})
|
||||
}
|
Loading…
Reference in a new issue