2017-07-23 20:12:17 +02:00
|
|
|
// Copyright 2016-2017, Pulumi Corporation. All rights reserved.
|
|
|
|
|
|
|
|
package examples
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"path"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
2017-10-28 05:03:38 +02:00
|
|
|
"github.com/pulumi/pulumi/pkg/resource/stack"
|
2017-09-22 04:18:21 +02:00
|
|
|
"github.com/pulumi/pulumi/pkg/testing/integration"
|
2017-07-23 20:12:17 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestExamples(t *testing.T) {
|
|
|
|
cwd, err := os.Getwd()
|
|
|
|
if !assert.NoError(t, err, "expected a valid working directory: %v", err) {
|
|
|
|
return
|
|
|
|
}
|
2017-10-23 04:03:08 +02:00
|
|
|
examples := []integration.ProgramTestOptions{
|
2017-08-06 17:26:20 +02:00
|
|
|
{
|
2017-10-12 15:05:14 +02:00
|
|
|
Dir: path.Join(cwd, "minimal"),
|
2017-09-22 04:18:21 +02:00
|
|
|
Dependencies: []string{"pulumi"},
|
2017-08-31 19:45:48 +02:00
|
|
|
Config: map[string]string{
|
2017-10-17 01:01:34 +02:00
|
|
|
"name": "Pulumi",
|
2017-08-06 17:26:20 +02:00
|
|
|
},
|
2017-10-19 00:37:18 +02:00
|
|
|
Secrets: map[string]string{
|
|
|
|
"secret": "this is my secret message",
|
|
|
|
},
|
2017-10-28 05:03:38 +02:00
|
|
|
ExtraRuntimeValidation: func(t *testing.T, checkpoint stack.Checkpoint) {
|
|
|
|
// Simple runtime validation that just ensures the checkpoint was written and read.
|
|
|
|
assert.Equal(t, integration.TestStackName, checkpoint.Target)
|
|
|
|
},
|
2017-07-23 20:12:17 +02:00
|
|
|
},
|
2017-10-12 00:27:34 +02:00
|
|
|
{
|
2017-10-14 02:48:54 +02:00
|
|
|
Dir: path.Join(cwd, "dynamic-provider/simple"),
|
2017-10-12 00:27:34 +02:00
|
|
|
Dependencies: []string{"pulumi"},
|
|
|
|
Config: map[string]string{
|
2017-10-05 23:08:35 +02:00
|
|
|
"simple:config:w": "1",
|
|
|
|
"simple:config:x": "1",
|
|
|
|
"simple:config:y": "1",
|
2017-10-12 00:27:34 +02:00
|
|
|
},
|
|
|
|
},
|
2017-10-26 20:30:25 +02:00
|
|
|
{
|
|
|
|
Dir: path.Join(cwd, "dynamic-provider/multiple-turns"),
|
|
|
|
Dependencies: []string{"pulumi"},
|
|
|
|
},
|
2017-07-23 20:12:17 +02:00
|
|
|
}
|
|
|
|
for _, ex := range examples {
|
|
|
|
example := ex
|
2017-08-06 17:26:20 +02:00
|
|
|
t.Run(example.Dir, func(t *testing.T) {
|
2017-10-23 04:03:08 +02:00
|
|
|
integration.ProgramTest(t, example)
|
2017-07-23 20:12:17 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|