-
Notifications
You must be signed in to change notification settings - Fork 104
/
examples_test.go
58 lines (49 loc) · 1.03 KB
/
examples_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package examples
import (
"fmt"
"os"
"testing"
"time"
"github.com/pulumi/pulumi/pkg/v3/testing/integration"
)
func getEnvRegion(t *testing.T) string {
envRegion := os.Getenv("AWS_REGION")
if envRegion == "" {
t.Skipf("Skipping test due to missing AWS_REGION environment variable")
}
fmt.Printf("AWS Region: %v\n", envRegion)
return envRegion
}
func getCwd(t *testing.T) string {
cwd, err := os.Getwd()
if err != nil {
t.FailNow()
}
return cwd
}
func getBaseOptions(t *testing.T) integration.ProgramTestOptions {
envRegion := getEnvRegion(t)
baseJS := integration.ProgramTestOptions{
Config: map[string]string{
"aws:region": envRegion,
},
Quick: true,
SkipRefresh: true,
ExpectRefreshChanges: true,
}
return baseJS
}
func maxDuration(dur time.Duration, t *testing.T, test func(t *testing.T)) {
t.Helper()
timeout := time.After(dur)
done := make(chan bool)
go func() {
test(t)
done <- true
}()
select {
case <-timeout:
t.Fatalf("Test timed out after %v", dur)
case <-done:
}
}