2020-07-07 23:25:11 +02:00
|
|
|
package auto
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2020-07-15 08:13:45 +02:00
|
|
|
func TestUpBasic(t *testing.T) {
|
2020-07-07 23:25:11 +02:00
|
|
|
p := Project{
|
|
|
|
Name: "testproj",
|
|
|
|
SourcePath: filepath.Join(".", "test", "testproj"),
|
|
|
|
}
|
|
|
|
s := &Stack{
|
|
|
|
Name: "int_test",
|
|
|
|
Project: p,
|
|
|
|
Overrides: &StackOverrides{
|
|
|
|
Config: map[string]string{"bar": "abc"},
|
|
|
|
Secrets: map[string]string{"buzz": "secret"},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
res, err := s.Up()
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("up failed, err: %v", err)
|
|
|
|
t.FailNow()
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, 2, len(res.Outputs), "expected two plain outputs")
|
|
|
|
assert.Equal(t, 1, len(res.SecretOutputs), "expected one secret output")
|
2020-07-15 08:13:45 +02:00
|
|
|
assert.Equal(t, "foo", res.Outputs["exp_static"])
|
|
|
|
assert.Equal(t, "abc", res.Outputs["exp_cfg"])
|
|
|
|
assert.Equal(t, "secret", res.SecretOutputs["exp_secret"])
|
2020-07-16 08:34:34 +02:00
|
|
|
assert.Equal(t, "update", res.Summary.Kind)
|
|
|
|
assert.Equal(t, "succeeded", res.Summary.Result)
|
2020-07-16 17:47:04 +02:00
|
|
|
|
|
|
|
dRes, err := s.Destroy()
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("destroy failed, err: %v", err)
|
|
|
|
t.FailNow()
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, "destroy", dRes.Summary.Kind)
|
|
|
|
assert.Equal(t, "succeeded", dRes.Summary.Result)
|
2020-07-17 03:50:34 +02:00
|
|
|
|
|
|
|
err = s.Remove()
|
|
|
|
assert.Nil(t, err, "failed to remove stack. Resources have leaked.")
|
2020-07-07 23:25:11 +02:00
|
|
|
}
|