Skip to content

Commit e15f40d

Browse files
committed
Refactor so resource ID set in only one place
1 parent 5552bef commit e15f40d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

internal/command/test_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -3976,17 +3976,17 @@ test_resource_id = 12345`
39763976
func TestTest_UseOfBackends_priorStateUsedByBackend(t *testing.T) {
39773977

39783978
dirName := "valid-use-local-backend/with-prior-state"
3979-
resourceId := "53d69028-477d-7ba0-83c3-ff3807e3756f"
3980-
expectedState := `test_resource.foobar:
3981-
ID = 53d69028-477d-7ba0-83c3-ff3807e3756f
3979+
resourceId := "53d69028-477d-7ba0-83c3-ff3807e3756f" // This value needs to match the state file in the test fixtures
3980+
expectedState := fmt.Sprintf(`test_resource.foobar:
3981+
ID = %s
39823982
provider = provider["registry.terraform.io/hashicorp/test"]
39833983
destroy_fail = false
39843984
value = value-from-run-that-controls-backend
39853985
39863986
Outputs:
39873987
39883988
supplied_input_value = value-from-run-that-controls-backend
3989-
test_resource_id = 53d69028-477d-7ba0-83c3-ff3807e3756f`
3989+
test_resource_id = %s`, resourceId, resourceId)
39903990

39913991
// SETUP
39923992
td := t.TempDir()
@@ -3998,8 +3998,8 @@ test_resource_id = 53d69028-477d-7ba0-83c3-ff3807e3756f`
39983998
// to resemble what's in state / the remote object being reused by the test.
39993999
resourceStore := &testing_command.ResourceStore{
40004000
Data: map[string]cty.Value{
4001-
"53d69028-477d-7ba0-83c3-ff3807e3756f": cty.ObjectVal(map[string]cty.Value{
4002-
"id": cty.StringVal("53d69028-477d-7ba0-83c3-ff3807e3756f"),
4001+
resourceId: cty.ObjectVal(map[string]cty.Value{
4002+
"id": cty.StringVal(resourceId),
40034003
"interrupt_count": cty.NullVal(cty.Number),
40044004
"value": cty.StringVal("value-from-run-that-controls-backend"),
40054005
"write_only": cty.NullVal(cty.String),

0 commit comments

Comments
 (0)