@@ -46,17 +46,14 @@ func TestIntegration(t *testing.T) {
46
46
ctx , cancel := context .WithTimeout (context .Background (), time .Duration (timeoutMins )* time .Minute )
47
47
t .Cleanup (cancel )
48
48
49
- // Given: we have an existing Coder deployment running locally
50
- ctrID := setup (ctx , t )
51
-
52
49
for _ , tt := range []struct {
53
50
// Name of the folder under `integration/` containing a test template
54
- templateName string
51
+ name string
55
52
// map of string to regex to be passed to assertOutput()
56
53
expectedOutput map [string ]string
57
54
}{
58
55
{
59
- templateName : "test-data-source" ,
56
+ name : "test-data-source" ,
60
57
expectedOutput : map [string ]string {
61
58
"provisioner.arch" : runtime .GOARCH ,
62
59
"provisioner.id" : `[a-zA-Z0-9-]+` ,
@@ -89,15 +86,17 @@ func TestIntegration(t *testing.T) {
89
86
},
90
87
},
91
88
} {
92
- t .Run (tt .templateName , func (t * testing.T ) {
89
+ t .Run (tt .name , func (t * testing.T ) {
90
+ // Given: we have an existing Coder deployment running locally
91
+ ctrID := setup (ctx , t , tt .name )
93
92
// Import named template
94
- _ , rc := execContainer (ctx , t , ctrID , fmt .Sprintf (`coder templates push %s --directory /src/integration/%s --var output_path=/tmp/%s.json --yes` , tt .templateName , tt .templateName , tt .templateName ))
93
+ _ , rc := execContainer (ctx , t , ctrID , fmt .Sprintf (`coder templates push %s --directory /src/integration/%s --var output_path=/tmp/%s.json --yes` , tt .name , tt .name , tt .name ))
95
94
require .Equal (t , 0 , rc )
96
95
// Create a workspace
97
- _ , rc = execContainer (ctx , t , ctrID , fmt .Sprintf (`coder create %s -t %s --yes` , tt .templateName , tt .templateName ))
96
+ _ , rc = execContainer (ctx , t , ctrID , fmt .Sprintf (`coder create %s -t %s --yes` , tt .name , tt .name ))
98
97
require .Equal (t , 0 , rc )
99
98
// Fetch the output created by the template
100
- out , rc := execContainer (ctx , t , ctrID , fmt .Sprintf (`cat /tmp/%s.json` , tt .templateName ))
99
+ out , rc := execContainer (ctx , t , ctrID , fmt .Sprintf (`cat /tmp/%s.json` , tt .name ))
101
100
require .Equal (t , 0 , rc )
102
101
actual := make (map [string ]string )
103
102
require .NoError (t , json .NewDecoder (strings .NewReader (out )).Decode (& actual ))
@@ -106,7 +105,7 @@ func TestIntegration(t *testing.T) {
106
105
}
107
106
}
108
107
109
- func setup (ctx context.Context , t * testing.T ) string {
108
+ func setup (ctx context.Context , t * testing.T , name string ) string {
110
109
var (
111
110
// For this test to work, we pass in a custom terraformrc to use
112
111
// the locally built version of the provider.
@@ -173,7 +172,7 @@ func setup(ctx context.Context, t *testing.T) string {
173
172
tfrcPath + ":/tmp/integration.tfrc" , // Custom tfrc from above.
174
173
srcPath + ":/src" , // Bind-mount in the repo with the built binary and templates.
175
174
},
176
- }, nil , nil , "" )
175
+ }, nil , nil , "terraform-provider-coder-integration-" + name )
177
176
require .NoError (t , err , "create test deployment" )
178
177
179
178
t .Logf ("created container %s\n " , ctr .ID )
0 commit comments