Skip to content

Commit cb96bfa

Browse files
authored
Merge pull request #83 from opencredo/modify-vm
Preventing VM recreation when `network_interface` is changed
2 parents 1932e27 + d90a901 commit cb96bfa

File tree

4 files changed

+163
-105
lines changed

4 files changed

+163
-105
lines changed

skytap/resource_label_category_test.go

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package skytap
33
import (
44
"context"
55
"fmt"
6-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
76
"log"
87
"regexp"
98
"strconv"
@@ -23,9 +22,7 @@ func init() {
2322
}
2423

2524
func TestAccSkytapLabelCategory_Basic(t *testing.T) {
26-
uniqueSuffix := acctest.RandInt()
27-
28-
label := fmt.Sprintf("tftest-label-%d", uniqueSuffix)
25+
label := fmt.Sprintf("tftest-label-%s", t.Name())
2926

3027
resource.ParallelTest(t, resource.TestCase{
3128
PreCheck: func() { testAccPreCheck(t) },
@@ -47,9 +44,7 @@ func TestAccSkytapLabelCategory_Basic(t *testing.T) {
4744
}
4845

4946
func TestAccSkytapLabelCategory_Update(t *testing.T) {
50-
uniqueSuffix := acctest.RandInt()
51-
52-
label := fmt.Sprintf("tftest-label-%d", uniqueSuffix)
47+
label := fmt.Sprintf("tftest-label-%s", t.Name())
5348

5449
resource.ParallelTest(t, resource.TestCase{
5550
PreCheck: func() { testAccPreCheck(t) },
@@ -61,19 +56,16 @@ func TestAccSkytapLabelCategory_Update(t *testing.T) {
6156
Check: testAccCheckSkytapLabelCategoryExists("skytap_label_category.env_category"),
6257
},
6358
{
64-
ExpectNonEmptyPlan: true,
65-
Config: testAccSkytapLabelCategory_basic(label, false),
66-
Check: testAccCheckSkytapLabelCategoryExists("skytap_label_category.env_category"),
67-
ExpectError: regexp.MustCompile(`can not be created with this single value property as it is recreated from a existing label category`),
59+
Config: testAccSkytapLabelCategory_basic(label, false),
60+
Check: testAccCheckSkytapLabelCategoryExists("skytap_label_category.env_category"),
61+
ExpectError: regexp.MustCompile(`can not be created with this single value property as it is recreated from a existing label category`),
6862
},
6963
},
7064
})
7165
}
7266

7367
func TestAccSkytapLabelCategory_MultiValueBasic(t *testing.T) {
74-
uniqueSuffix := acctest.RandInt()
75-
76-
label := fmt.Sprintf("tftest-label-multi-%d", uniqueSuffix)
68+
label := fmt.Sprintf("tftest-label-multi-%s", t.Name())
7769

7870
resource.ParallelTest(t, resource.TestCase{
7971
PreCheck: func() { testAccPreCheck(t) },
@@ -95,20 +87,20 @@ func TestAccSkytapLabelCategory_MultiValueBasic(t *testing.T) {
9587
}
9688

9789
func TestAccSkytapLabelCategory_Duplicated(t *testing.T) {
98-
labelCategoryDuplicated := `
90+
labelCategoryDuplicated := fmt.Sprintf(`
9991
resource skytap_label_category "duplabel1" {
100-
name = "tftest-dup"
92+
name = "tftest-dup-%s"
10193
single_value = true
10294
}
10395
10496
resource skytap_label_category "duplabel2" {
10597
// making sure the first category is created before trying to create the second
10698
// to avoid flakiness.
10799
depends_on = [skytap_label_category.duplabel1]
108-
name = "tftest-dup"
100+
name = "tftest-dup-%s"
109101
single_value = true
110102
}
111-
`
103+
`, t.Name(), t.Name())
112104
expectedError := regexp.MustCompile(".* Validation failed: Name has already been taken")
113105
resource.ParallelTest(t, resource.TestCase{
114106
PreCheck: func() { testAccPreCheck(t) },

skytap/resource_skytap_environment_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,15 @@ func TestAccSkytapEnvironment_UserDataUpdate(t *testing.T) {
244244
})
245245
}
246246

247-
func labelRequirements(uniqueSuffix int) string {
247+
func labelRequirements(uniqueSuffix string) string {
248248
return fmt.Sprintf(`
249249
resource skytap_label_category "environment_label" {
250-
name = "tftest-Environment-%d"
250+
name = "tftest-Environment-%s"
251251
single_value = true
252252
}
253253
254254
resource skytap_label_category "owners_label" {
255-
name = "tftest-Owners-%d"
255+
name = "tftest-Owners-%s"
256256
single_value = false
257257
}
258258
`, uniqueSuffix, uniqueSuffix)
@@ -285,7 +285,7 @@ func TestAccSkytapEnvironment_Labels(t *testing.T) {
285285
Steps: []resource.TestStep{
286286
{
287287
PreventDiskCleanup: true,
288-
Config: testAccSkytapEnvironmentConfigBlock(uniqueSuffix, templateID, labelRequirements(uniqueSuffix), labels),
288+
Config: testAccSkytapEnvironmentConfigBlock(uniqueSuffix, templateID, labelRequirements(t.Name()), labels),
289289
Check: resource.ComposeTestCheckFunc(
290290
testAccCheckSkytapEnvironmentExists("skytap_environment.foo", &environment),
291291
),
@@ -325,8 +325,8 @@ func TestAccSkytapEnvironment_LabelsUpdate(t *testing.T) {
325325
}
326326
`
327327

328-
labelEnv := fmt.Sprintf("tftest-Environment-%d", uniqueSuffix)
329-
labelOwners := fmt.Sprintf("tftest-Owners-%d", uniqueSuffix)
328+
labelEnv := fmt.Sprintf("tftest-Environment-%s", t.Name())
329+
labelOwners := fmt.Sprintf("tftest-Owners-%s", t.Name())
330330

331331
resource.ParallelTest(t, resource.TestCase{
332332
PreCheck: func() { testAccPreCheck(t) },
@@ -335,7 +335,7 @@ func TestAccSkytapEnvironment_LabelsUpdate(t *testing.T) {
335335
Steps: []resource.TestStep{
336336
{
337337
PreventDiskCleanup: true,
338-
Config: testAccSkytapEnvironmentConfigBlock(uniqueSuffix, templateID, labelRequirements(uniqueSuffix), labels),
338+
Config: testAccSkytapEnvironmentConfigBlock(uniqueSuffix, templateID, labelRequirements(t.Name()), labels),
339339
Check: resource.ComposeTestCheckFunc(
340340
testAccCheckSkytapEnvironmentExists("skytap_environment.foo", &environment),
341341
testAccCheckSkytapEnvironmentContainsLabel(&environment, labelEnv, "Prod"),
@@ -345,7 +345,7 @@ func TestAccSkytapEnvironment_LabelsUpdate(t *testing.T) {
345345
},
346346
{
347347
PreventDiskCleanup: true,
348-
Config: testAccSkytapEnvironmentConfigBlock(uniqueSuffix, templateID, labelRequirements(uniqueSuffix), labelsUpdated),
348+
Config: testAccSkytapEnvironmentConfigBlock(uniqueSuffix, templateID, labelRequirements(t.Name()), labelsUpdated),
349349
Check: resource.ComposeTestCheckFunc(
350350
testAccCheckSkytapEnvironmentExists("skytap_environment.foo", &environment),
351351
testAccCheckSkytapEnvironmentContainsLabel(&environment, labelEnv, "UAT"),

0 commit comments

Comments
 (0)