Skip to content

Commit df00c26

Browse files
committed
test: move ImportState scheduled rebalancing test cases to the end
1 parent c542936 commit df00c26

1 file changed

Lines changed: 18 additions & 13 deletions

File tree

castai/resource_rebalancing_schedule_test.go

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,6 @@ func TestAccResourceRebalancingSchedule_basic(t *testing.T) {
2323
resource.TestCheckResourceAttr("castai_rebalancing_schedule.test", "schedule.0.cron", "5 4 * * *"),
2424
),
2525
},
26-
{
27-
// import by ID
28-
ImportState: true,
29-
ResourceName: "castai_rebalancing_schedule.test",
30-
ImportStateVerify: true,
31-
},
32-
{
33-
// import by name
34-
ImportState: true,
35-
ResourceName: "castai_rebalancing_schedule.test",
36-
ImportStateId: rName,
37-
ImportStateVerify: true,
38-
},
3926
{
4027
// test edits
4128
Config: makeUpdatedRebalancingScheduleConfig(rName + " renamed"),
@@ -56,6 +43,24 @@ func TestAccResourceRebalancingSchedule_basic(t *testing.T) {
5643
resource.TestCheckResourceAttr("castai_rebalancing_schedule.test", "launch_configuration.0.rebalancing_min_nodes", "0"),
5744
),
5845
},
46+
// We keep the ImportState test cases at the end so they will test any newly added fields.
47+
// This way it will also verify that after importing the state the output of `tf plan` is empty.
48+
{
49+
// Import state by ID
50+
ImportState: true,
51+
ResourceName: "castai_rebalancing_schedule.test",
52+
ImportStateVerify: true,
53+
},
54+
{
55+
// Import state by name
56+
ImportState: true,
57+
ResourceName: "castai_rebalancing_schedule.test",
58+
// Make sure to use the resource (rebalancing schedule) name from the latest prior step that changes the resource,
59+
// otherwise this step will not to see the changes made after the State ID you provided,
60+
// and this step will fail.
61+
ImportStateId: rName + " min_nodes_zero",
62+
ImportStateVerify: true,
63+
},
5964
},
6065
})
6166
}

0 commit comments

Comments
 (0)