@@ -361,7 +361,7 @@ func Test_ExpectUnknownOutputValueAtPath_SetNestedBlock_Object(t *testing.T) {
361
361
})
362
362
}
363
363
364
- func Test_ExpectUnknownOutputValueAtPath_ExpectError_KnownValue (t * testing.T ) {
364
+ func Test_ExpectUnknownOutputValueAtPath_ExpectError_KnownValue_PathNotFound (t * testing.T ) {
365
365
t .Parallel ()
366
366
367
367
r .UnitTest (t , r.TestCase {
@@ -381,7 +381,201 @@ func Test_ExpectUnknownOutputValueAtPath_ExpectError_KnownValue(t *testing.T) {
381
381
{
382
382
Config : `
383
383
resource "test_resource" "one" {
384
- set_attribute = ["value1"]
384
+ list_nested_block {
385
+ list_nested_block_attribute = "value 1"
386
+ }
387
+ }
388
+
389
+ output "resource" {
390
+ value = test_resource.one
391
+ }
392
+ ` ,
393
+ ConfigPlanChecks : r.ConfigPlanChecks {
394
+ PreApply : []plancheck.PlanCheck {
395
+ plancheck .ExpectUnknownOutputValueAtPath ("resource" , tfjsonpath .New ("list_nested_block" ).AtSliceIndex (0 ).AtMapKey ("not_correct_attr" )),
396
+ },
397
+ },
398
+ ExpectError : regexp .MustCompile (`path not found: specified key not_correct_attr not found in map at list_nested_block.0.not_correct_attr` ),
399
+ },
400
+ },
401
+ })
402
+ }
403
+
404
+ func Test_ExpectUnknownOutputValueAtPath_ExpectError_KnownValue_ListAttribute (t * testing.T ) {
405
+ t .Parallel ()
406
+
407
+ r .UnitTest (t , r.TestCase {
408
+ ProviderFactories : map [string ]func () (* schema.Provider , error ){
409
+ "test" : func () (* schema.Provider , error ) { //nolint:unparam // required signature
410
+ return testProvider (), nil
411
+ },
412
+ },
413
+ // Prior to Terraform v1.3.0 a planned output is marked as fully unknown
414
+ // if any attribute is unknown. The id attribute within the test provider
415
+ // is unknown.
416
+ // Reference: https://github.com/hashicorp/terraform/blob/v1.3/CHANGELOG.md#130-september-21-2022
417
+ TerraformVersionChecks : []tfversion.TerraformVersionCheck {
418
+ tfversion .SkipBelow (tfversion .Version1_3_0 ),
419
+ },
420
+ Steps : []r.TestStep {
421
+ {
422
+ Config : `
423
+ resource "test_resource" "one" {
424
+ list_attribute = ["value1"]
425
+ }
426
+
427
+ output "resource" {
428
+ value = test_resource.one
429
+ }
430
+ ` ,
431
+ ConfigPlanChecks : r.ConfigPlanChecks {
432
+ PreApply : []plancheck.PlanCheck {
433
+ plancheck .ExpectUnknownOutputValueAtPath ("resource" , tfjsonpath .New ("list_attribute" ).AtSliceIndex (0 )),
434
+ },
435
+ },
436
+ ExpectError : regexp .MustCompile (`Expected unknown value at output "resource" path "list_attribute.0", but found known value: "value1"` ),
437
+ },
438
+ },
439
+ })
440
+ }
441
+
442
+ func Test_ExpectUnknownOutputValueAtPath_ExpectError_KnownValue_StringAttribute (t * testing.T ) {
443
+ t .Parallel ()
444
+
445
+ r .UnitTest (t , r.TestCase {
446
+ ProviderFactories : map [string ]func () (* schema.Provider , error ){
447
+ "test" : func () (* schema.Provider , error ) { //nolint:unparam // required signature
448
+ return testProvider (), nil
449
+ },
450
+ },
451
+ // Prior to Terraform v1.3.0 a planned output is marked as fully unknown
452
+ // if any attribute is unknown. The id attribute within the test provider
453
+ // is unknown.
454
+ // Reference: https://github.com/hashicorp/terraform/blob/v1.3/CHANGELOG.md#130-september-21-2022
455
+ TerraformVersionChecks : []tfversion.TerraformVersionCheck {
456
+ tfversion .SkipBelow (tfversion .Version1_3_0 ),
457
+ },
458
+ Steps : []r.TestStep {
459
+ {
460
+ Config : `
461
+ resource "test_resource" "one" {
462
+ string_attribute = "hello world!"
463
+ }
464
+
465
+ output "resource" {
466
+ value = test_resource.one
467
+ }
468
+ ` ,
469
+ ConfigPlanChecks : r.ConfigPlanChecks {
470
+ PreApply : []plancheck.PlanCheck {
471
+ plancheck .ExpectUnknownOutputValueAtPath ("resource" , tfjsonpath .New ("string_attribute" )),
472
+ },
473
+ },
474
+ ExpectError : regexp .MustCompile (`Expected unknown value at output "resource" path "string_attribute", but found known value: "hello world!"` ),
475
+ },
476
+ },
477
+ })
478
+ }
479
+
480
+ func Test_ExpectUnknownOutputValueAtPath_ExpectError_KnownValue_BoolAttribute (t * testing.T ) {
481
+ t .Parallel ()
482
+
483
+ r .UnitTest (t , r.TestCase {
484
+ ProviderFactories : map [string ]func () (* schema.Provider , error ){
485
+ "test" : func () (* schema.Provider , error ) { //nolint:unparam // required signature
486
+ return testProvider (), nil
487
+ },
488
+ },
489
+ // Prior to Terraform v1.3.0 a planned output is marked as fully unknown
490
+ // if any attribute is unknown. The id attribute within the test provider
491
+ // is unknown.
492
+ // Reference: https://github.com/hashicorp/terraform/blob/v1.3/CHANGELOG.md#130-september-21-2022
493
+ TerraformVersionChecks : []tfversion.TerraformVersionCheck {
494
+ tfversion .SkipBelow (tfversion .Version1_3_0 ),
495
+ },
496
+ Steps : []r.TestStep {
497
+ {
498
+ Config : `
499
+ resource "test_resource" "one" {
500
+ bool_attribute = true
501
+ }
502
+
503
+ output "resource" {
504
+ value = test_resource.one
505
+ }
506
+ ` ,
507
+ ConfigPlanChecks : r.ConfigPlanChecks {
508
+ PreApply : []plancheck.PlanCheck {
509
+ plancheck .ExpectUnknownOutputValueAtPath ("resource" , tfjsonpath .New ("bool_attribute" )),
510
+ },
511
+ },
512
+ ExpectError : regexp .MustCompile (`Expected unknown value at output "resource" path "bool_attribute", but found known value: "true"` ),
513
+ },
514
+ },
515
+ })
516
+ }
517
+
518
+ func Test_ExpectUnknownOutputValueAtPath_ExpectError_KnownValue_FloatAttribute (t * testing.T ) {
519
+ t .Parallel ()
520
+
521
+ r .UnitTest (t , r.TestCase {
522
+ ProviderFactories : map [string ]func () (* schema.Provider , error ){
523
+ "test" : func () (* schema.Provider , error ) { //nolint:unparam // required signature
524
+ return testProvider (), nil
525
+ },
526
+ },
527
+ // Prior to Terraform v1.3.0 a planned output is marked as fully unknown
528
+ // if any attribute is unknown. The id attribute within the test provider
529
+ // is unknown.
530
+ // Reference: https://github.com/hashicorp/terraform/blob/v1.3/CHANGELOG.md#130-september-21-2022
531
+ TerraformVersionChecks : []tfversion.TerraformVersionCheck {
532
+ tfversion .SkipBelow (tfversion .Version1_3_0 ),
533
+ },
534
+ Steps : []r.TestStep {
535
+ {
536
+ Config : `
537
+ resource "test_resource" "one" {
538
+ float_attribute = 1.234
539
+ }
540
+
541
+ output "resource" {
542
+ value = test_resource.one
543
+ }
544
+ ` ,
545
+ ConfigPlanChecks : r.ConfigPlanChecks {
546
+ PreApply : []plancheck.PlanCheck {
547
+ plancheck .ExpectUnknownOutputValueAtPath ("resource" , tfjsonpath .New ("float_attribute" )),
548
+ },
549
+ },
550
+ ExpectError : regexp .MustCompile (`Expected unknown value at output "resource" path "float_attribute", but found known value: "1.234"` ),
551
+ },
552
+ },
553
+ })
554
+ }
555
+
556
+ func Test_ExpectUnknownOutputValueAtPath_ExpectError_KnownValue_ListNestedBlock (t * testing.T ) {
557
+ t .Parallel ()
558
+
559
+ r .UnitTest (t , r.TestCase {
560
+ ProviderFactories : map [string ]func () (* schema.Provider , error ){
561
+ "test" : func () (* schema.Provider , error ) { //nolint:unparam // required signature
562
+ return testProvider (), nil
563
+ },
564
+ },
565
+ // Prior to Terraform v1.3.0 a planned output is marked as fully unknown
566
+ // if any attribute is unknown. The id attribute within the test provider
567
+ // is unknown.
568
+ // Reference: https://github.com/hashicorp/terraform/blob/v1.3/CHANGELOG.md#130-september-21-2022
569
+ TerraformVersionChecks : []tfversion.TerraformVersionCheck {
570
+ tfversion .SkipBelow (tfversion .Version1_3_0 ),
571
+ },
572
+ Steps : []r.TestStep {
573
+ {
574
+ Config : `
575
+ resource "test_resource" "one" {
576
+ list_nested_block {
577
+ list_nested_block_attribute = "value 1"
578
+ }
385
579
}
386
580
387
581
output "resource" {
@@ -390,10 +584,10 @@ func Test_ExpectUnknownOutputValueAtPath_ExpectError_KnownValue(t *testing.T) {
390
584
` ,
391
585
ConfigPlanChecks : r.ConfigPlanChecks {
392
586
PreApply : []plancheck.PlanCheck {
393
- plancheck .ExpectUnknownOutputValueAtPath ("resource" , tfjsonpath .New ("set_attribute " ).AtSliceIndex (0 )),
587
+ plancheck .ExpectUnknownOutputValueAtPath ("resource" , tfjsonpath .New ("list_nested_block " ).AtSliceIndex (0 ). AtMapKey ( "list_nested_block_attribute" )),
394
588
},
395
589
},
396
- ExpectError : regexp .MustCompile (`attribute at path is known` ),
590
+ ExpectError : regexp .MustCompile (`Expected unknown value at output "resource" path "list_nested_block.0.list_nested_block_attribute", but found known value: "value 1" ` ),
397
591
},
398
592
},
399
593
})
0 commit comments