Skip to content

Commit 7045b29

Browse files
committed
fix: update 'UnknownUsesStateInOrder' test to capture when config name is null or non-null
1 parent 95a5032 commit 7045b29

1 file changed

Lines changed: 59 additions & 1 deletion

File tree

internal/provider/template_resource_test.go

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1388,6 +1388,8 @@ func TestReconcileVersionIDs(t *testing.T) {
13881388
},
13891389
},
13901390
{
1391+
// Config name is null (auto-generated), plan name is unknown.
1392+
// Should backfill name from state since the user didn't set one.
13911393
Name: "UnknownUsesStateInOrder",
13921394
planVersions: []TemplateVersion{
13931395
{
@@ -1408,7 +1410,7 @@ func TestReconcileVersionIDs(t *testing.T) {
14081410
Name: types.StringValue("foo"),
14091411
},
14101412
{
1411-
Name: types.StringValue("bar"),
1413+
Name: types.StringNull(),
14121414
},
14131415
},
14141416
inputState: map[string][]PreviousTemplateVersion{
@@ -1440,6 +1442,62 @@ func TestReconcileVersionIDs(t *testing.T) {
14401442
},
14411443
},
14421444
},
1445+
{
1446+
// Config name is non-null (e.g. random_uuid.result), plan name is unknown
1447+
// because the upstream resource is being recreated.
1448+
// Should NOT backfill name — leave it unknown to resolve after apply.
1449+
Name: "UnknownNonNullConfigNameNotBackfilled",
1450+
planVersions: []TemplateVersion{
1451+
{
1452+
Name: types.StringValue("foo"),
1453+
DirectoryHash: types.StringValue("aaa"),
1454+
ID: NewUUIDUnknown(),
1455+
TerraformVariables: []Variable{},
1456+
},
1457+
{
1458+
Name: types.StringUnknown(),
1459+
DirectoryHash: types.StringValue("aaa"),
1460+
ID: NewUUIDUnknown(),
1461+
TerraformVariables: []Variable{},
1462+
},
1463+
},
1464+
configVersions: []TemplateVersion{
1465+
{
1466+
Name: types.StringValue("foo"),
1467+
},
1468+
{
1469+
Name: types.StringValue("bar"),
1470+
},
1471+
},
1472+
inputState: map[string][]PreviousTemplateVersion{
1473+
"aaa": {
1474+
{
1475+
ID: aUUID,
1476+
Name: "qux",
1477+
TFVars: map[string]string{},
1478+
},
1479+
{
1480+
ID: bUUID,
1481+
Name: "baz",
1482+
TFVars: map[string]string{},
1483+
},
1484+
},
1485+
},
1486+
expectedVersions: []TemplateVersion{
1487+
{
1488+
Name: types.StringValue("foo"),
1489+
DirectoryHash: types.StringValue("aaa"),
1490+
ID: UUIDValue(aUUID),
1491+
TerraformVariables: []Variable{},
1492+
},
1493+
{
1494+
Name: types.StringUnknown(),
1495+
DirectoryHash: types.StringValue("aaa"),
1496+
ID: UUIDValue(bUUID),
1497+
TerraformVariables: []Variable{},
1498+
},
1499+
},
1500+
},
14431501
{
14441502
Name: "NewVersionNewRandomName",
14451503
planVersions: []TemplateVersion{

0 commit comments

Comments
 (0)