Skip to content

Commit 7a6bb17

Browse files
committed
name container properly
1 parent a4aae83 commit 7a6bb17

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

integration/integration_test.go

+10-11
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,14 @@ func TestIntegration(t *testing.T) {
4646
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(timeoutMins)*time.Minute)
4747
t.Cleanup(cancel)
4848

49-
// Given: we have an existing Coder deployment running locally
50-
ctrID := setup(ctx, t)
51-
5249
for _, tt := range []struct {
5350
// Name of the folder under `integration/` containing a test template
54-
templateName string
51+
name string
5552
// map of string to regex to be passed to assertOutput()
5653
expectedOutput map[string]string
5754
}{
5855
{
59-
templateName: "test-data-source",
56+
name: "test-data-source",
6057
expectedOutput: map[string]string{
6158
"provisioner.arch": runtime.GOARCH,
6259
"provisioner.id": `[a-zA-Z0-9-]+`,
@@ -89,15 +86,17 @@ func TestIntegration(t *testing.T) {
8986
},
9087
},
9188
} {
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)
9392
// 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))
9594
require.Equal(t, 0, rc)
9695
// 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))
9897
require.Equal(t, 0, rc)
9998
// 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))
101100
require.Equal(t, 0, rc)
102101
actual := make(map[string]string)
103102
require.NoError(t, json.NewDecoder(strings.NewReader(out)).Decode(&actual))
@@ -106,7 +105,7 @@ func TestIntegration(t *testing.T) {
106105
}
107106
}
108107

109-
func setup(ctx context.Context, t *testing.T) string {
108+
func setup(ctx context.Context, t *testing.T, name string) string {
110109
var (
111110
// For this test to work, we pass in a custom terraformrc to use
112111
// the locally built version of the provider.
@@ -173,7 +172,7 @@ func setup(ctx context.Context, t *testing.T) string {
173172
tfrcPath + ":/tmp/integration.tfrc", // Custom tfrc from above.
174173
srcPath + ":/src", // Bind-mount in the repo with the built binary and templates.
175174
},
176-
}, nil, nil, "")
175+
}, nil, nil, "terraform-provider-coder-integration-"+name)
177176
require.NoError(t, err, "create test deployment")
178177

179178
t.Logf("created container %s\n", ctr.ID)

0 commit comments

Comments
 (0)