-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19233 from hashicorp/jbardin/requires-new
fix instance replacement
- Loading branch information
Showing
8 changed files
with
330 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package test | ||
|
||
import ( | ||
"github.com/hashicorp/terraform/helper/schema" | ||
) | ||
|
||
func testResourceForceNew() *schema.Resource { | ||
return &schema.Resource{ | ||
Create: testResourceForceNewCreate, | ||
Read: testResourceForceNewRead, | ||
Delete: testResourceForceNewDelete, | ||
|
||
Importer: &schema.ResourceImporter{ | ||
State: schema.ImportStatePassthrough, | ||
}, | ||
|
||
Schema: map[string]*schema.Schema{ | ||
"triggers": { | ||
Type: schema.TypeMap, | ||
Optional: true, | ||
ForceNew: true, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func testResourceForceNewCreate(d *schema.ResourceData, meta interface{}) error { | ||
d.SetId("testId") | ||
return testResourceForceNewRead(d, meta) | ||
} | ||
|
||
func testResourceForceNewRead(d *schema.ResourceData, meta interface{}) error { | ||
return nil | ||
} | ||
|
||
func testResourceForceNewDelete(d *schema.ResourceData, meta interface{}) error { | ||
d.SetId("") | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package test | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform/helper/resource" | ||
) | ||
|
||
func TestResourceForceNew_create(t *testing.T) { | ||
resource.UnitTest(t, resource.TestCase{ | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckResourceDestroy, | ||
Steps: []resource.TestStep{ | ||
resource.TestStep{ | ||
Config: strings.TrimSpace(` | ||
resource "test_resource_force_new" "foo" { | ||
triggers = { | ||
"a" = "foo" | ||
} | ||
}`), | ||
}, | ||
}, | ||
}) | ||
} | ||
func TestResourceForceNew_update(t *testing.T) { | ||
resource.UnitTest(t, resource.TestCase{ | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckResourceDestroy, | ||
Steps: []resource.TestStep{ | ||
resource.TestStep{ | ||
Config: strings.TrimSpace(` | ||
resource "test_resource_force_new" "foo" { | ||
triggers = { | ||
"a" = "foo" | ||
} | ||
}`), | ||
}, | ||
resource.TestStep{ | ||
Config: strings.TrimSpace(` | ||
resource "test_resource_force_new" "foo" { | ||
triggers = { | ||
"a" = "bar" | ||
} | ||
}`), | ||
}, | ||
resource.TestStep{ | ||
Config: strings.TrimSpace(` | ||
resource "test_resource_force_new" "foo" { | ||
triggers = { | ||
"b" = "bar" | ||
} | ||
}`), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestResourceForceNew_remove(t *testing.T) { | ||
resource.UnitTest(t, resource.TestCase{ | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckResourceDestroy, | ||
Steps: []resource.TestStep{ | ||
resource.TestStep{ | ||
Config: strings.TrimSpace(` | ||
resource "test_resource_force_new" "foo" { | ||
triggers = { | ||
"a" = "bar" | ||
} | ||
}`), | ||
}, | ||
resource.TestStep{ | ||
Config: strings.TrimSpace(` | ||
resource "test_resource_force_new" "foo" { | ||
} `), | ||
}, | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters