Skip to content

Commit 1b47671

Browse files
committed
update comment on real example test to reflect current understanding
1 parent 805da5a commit 1b47671

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

helper/resource/testing_new_import_block_id_test.go

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -341,33 +341,27 @@ func TestTest_TestStep_ImportBlockId_SkipDataSourceState(t *testing.T) {
341341
// to do the state comparison doesn't return an error if there is no state in the working directory
342342
func TestTest_TestStep_ImportBlockId_ImportStateVerifyIgnore_Real_Example(t *testing.T) {
343343
/*
344-
This test tries to imitate a real world example of behaviour we often see in the AzureRM provider which requires
345-
the use of `ImportStateVerifyIgnore` when testing the import of a resource using the import command.
344+
This test tries to imitate a real world example of behaviour we often see in the AzureRM provider which requires
345+
the use of `ImportStateVerifyIgnore` when testing the import of a resource using the import command.
346346
347-
A sensitive field e.g. a password can be supplied on create but isn't returned in the API response on a subsequent
348-
read, resulting in a different value for password in the two states.
347+
A sensitive field e.g. a password can be supplied on create but isn't returned in the API response on a subsequent
348+
read, resulting in a different value for password in the two states.
349349
350-
In the AzureRM provider this is usually handled one of two ways, both requiring `ImportStateVerifyIgnore` to make
351-
the test pass:
350+
In the AzureRM provider this is usually handled one of two ways, both requiring `ImportStateVerifyIgnore` to make
351+
the test pass:
352352
353-
1. Property doesn't get set in the read
354-
* in pluginSDK at create the config gets written to state because that's what we're expecting
355-
* the subsequent read updates the values to create a post-apply diff and update computed values
356-
* since we don't do anything to the property in the read the imported resource's state has the password missing
357-
compared to the created resource's state
353+
1. Property doesn't get set in the read
354+
* in pluginSDK at create the config gets written to state because that's what we're expecting
355+
* the subsequent read updates the values to create a post-apply diff and update computed values
356+
* since we don't do anything to the property in the read the imported resource's state has the password missing
357+
compared to the created resource's state
358358
359-
2. We retrieve the value from config and set that into state
360-
* the config isn't available at import time using only the import command (I think?) so there is nothing to
361-
retrieve and set into state when importing
359+
2. We retrieve the value from config and set that into state
360+
* the config isn't available at import time using only the import command (I think?) so there is nothing to
361+
retrieve and set into state when importing
362362
363-
For this test to pass I needed to add a `PlanChangeFunc` to the resource to set the id to a known value in the plan - see comment in the `PlanChangeFunc`
364-
365-
I also need to omit the `password` in the import config, otherwise the value in the config is used when importing the resource and the test
366-
ends up passing regardless of whether `ImportStateVerifyIgnore` has been specified or not
367-
368-
Ultimately it looks like:
369-
* Terraform is saying there's a bug in the provider? (see comment in `PlanChangeFunc`)
370-
* The import behaviour using a block vs. the command appears to differ
363+
I also need to omit the `password` in the import config, otherwise the value in the config is used when importing the
364+
with an import block and the test ends up passing regardless of whether `ImportStateVerifyIgnore` has been specified or not
371365
*/
372366
t.Parallel()
373367

0 commit comments

Comments
 (0)