@@ -488,43 +488,49 @@ func TestBasicDetailedDiff(t *testing.T) {
488
488
"foo" : tt .value1 ,
489
489
},
490
490
)
491
- propertyMapSecretValue1 ["foo" ] = resource .NewSecretProperty (& resource.Secret {Element : propertyMapValue1 ["foo" ]})
491
+ propertyMapSecretValue1 ["foo" ] = resource .NewSecretProperty (
492
+ & resource.Secret {Element : propertyMapSecretValue1 ["foo" ]})
492
493
493
494
propertyMapSecretValue2 := resource .NewPropertyMapFromMap (
494
495
map [string ]interface {}{
495
496
"foo" : tt .value2 ,
496
497
},
497
498
)
498
- propertyMapSecretValue2 ["foo" ] = resource .NewSecretProperty (& resource.Secret {Element : propertyMapValue2 ["foo" ]})
499
+ propertyMapSecretValue2 ["foo" ] = resource .NewSecretProperty (
500
+ & resource.Secret {Element : propertyMapSecretValue2 ["foo" ]})
499
501
500
502
propertyMapOutputValue1 := resource .NewPropertyMapFromMap (
501
503
map [string ]interface {}{
502
504
"foo" : tt .value1 ,
503
505
},
504
506
)
505
- propertyMapOutputValue1 ["foo" ] = resource .NewOutputProperty (resource.Output {Element : propertyMapValue1 ["foo" ]})
507
+ propertyMapOutputValue1 ["foo" ] = resource .NewOutputProperty (
508
+ resource.Output {Element : propertyMapOutputValue1 ["foo" ], Known : true })
506
509
507
510
propertyMapOutputValue2 := resource .NewPropertyMapFromMap (
508
511
map [string ]interface {}{
509
512
"foo" : tt .value2 ,
510
513
},
511
514
)
512
- propertyMapOutputValue2 ["foo" ] = resource .NewOutputProperty (resource.Output {Element : propertyMapValue2 ["foo" ]})
515
+ propertyMapOutputValue2 ["foo" ] = resource .NewOutputProperty (
516
+ resource.Output {Element : propertyMapOutputValue2 ["foo" ], Known : true })
517
+
518
+ defaultChangePath := "foo"
519
+ if tt .listLike && tt .objectLike {
520
+ defaultChangePath = "foo[0].foo"
521
+ } else if tt .listLike {
522
+ defaultChangePath = "foo[0]"
523
+ } else if tt .objectLike {
524
+ defaultChangePath = "foo.foo"
525
+ }
513
526
514
527
t .Run ("unchanged" , func (t * testing.T ) {
515
528
runDetailedDiffTest (t , propertyMapValue1 , propertyMapValue1 , tfs , ps , map [string ]* pulumirpc.PropertyDiff {})
516
529
})
517
530
518
531
t .Run ("changed non-empty" , func (t * testing.T ) {
519
- expected := make (map [string ]* pulumirpc.PropertyDiff )
520
- if tt .listLike && tt .objectLike {
521
- expected ["foo[0].foo" ] = & pulumirpc.PropertyDiff {Kind : pulumirpc .PropertyDiff_UPDATE }
522
- } else if tt .listLike {
523
- expected ["foo[0]" ] = & pulumirpc.PropertyDiff {Kind : pulumirpc .PropertyDiff_UPDATE }
524
- } else if tt .objectLike {
525
- expected ["foo.foo" ] = & pulumirpc.PropertyDiff {Kind : pulumirpc .PropertyDiff_UPDATE }
526
- } else {
527
- expected ["foo" ] = & pulumirpc.PropertyDiff {Kind : pulumirpc .PropertyDiff_UPDATE }
532
+ expected := map [string ]* pulumirpc.PropertyDiff {
533
+ defaultChangePath : {Kind : pulumirpc .PropertyDiff_UPDATE },
528
534
}
529
535
runDetailedDiffTest (t , propertyMapValue1 , propertyMapValue2 , tfs , ps , expected )
530
536
})
@@ -612,7 +618,10 @@ func TestBasicDetailedDiff(t *testing.T) {
612
618
})
613
619
614
620
t .Run ("secret changed" , func (t * testing.T ) {
615
- runDetailedDiffTest (t , propertyMapSecretValue1 , propertyMapSecretValue2 , tfs , ps , updated ())
621
+ expected := map [string ]* pulumirpc.PropertyDiff {
622
+ defaultChangePath : {Kind : pulumirpc .PropertyDiff_UPDATE },
623
+ }
624
+ runDetailedDiffTest (t , propertyMapSecretValue1 , propertyMapSecretValue2 , tfs , ps , expected )
616
625
})
617
626
618
627
t .Run ("output unchanged" , func (t * testing.T ) {
@@ -634,7 +643,10 @@ func TestBasicDetailedDiff(t *testing.T) {
634
643
})
635
644
636
645
t .Run ("output changed" , func (t * testing.T ) {
637
- runDetailedDiffTest (t , propertyMapOutputValue1 , propertyMapOutputValue2 , tfs , ps , updated ())
646
+ expected := map [string ]* pulumirpc.PropertyDiff {
647
+ defaultChangePath : {Kind : pulumirpc .PropertyDiff_UPDATE },
648
+ }
649
+ runDetailedDiffTest (t , propertyMapOutputValue1 , propertyMapOutputValue2 , tfs , ps , expected )
638
650
})
639
651
})
640
652
}
@@ -682,6 +694,16 @@ func TestDetailedDiffObject(t *testing.T) {
682
694
},
683
695
)
684
696
697
+ propertyMapWithSecrets := resource.PropertyMap {
698
+ resource .PropertyKey ("foo" ): resource .NewPropertyValue (
699
+ resource.PropertyMap {
700
+ resource .PropertyKey ("prop1" ): resource .NewSecretProperty (
701
+ & resource.Secret {Element : resource .NewStringProperty ("val1" )}),
702
+ resource .PropertyKey ("prop2" ): resource .NewStringProperty ("qux" ),
703
+ },
704
+ ),
705
+ }
706
+
685
707
t .Run ("unchanged" , func (t * testing.T ) {
686
708
runDetailedDiffTest (t , propertyMapProp1Val1 , propertyMapProp1Val1 , tfs , ps , map [string ]* pulumirpc.PropertyDiff {})
687
709
})
@@ -723,6 +745,18 @@ func TestDetailedDiffObject(t *testing.T) {
723
745
"foo.prop2" : {Kind : pulumirpc .PropertyDiff_ADD },
724
746
})
725
747
})
748
+
749
+ t .Run ("secret added" , func (t * testing.T ) {
750
+ runDetailedDiffTest (t , propertyMapProp2 , propertyMapWithSecrets , tfs , ps , map [string ]* pulumirpc.PropertyDiff {
751
+ "foo.prop1" : {Kind : pulumirpc .PropertyDiff_ADD },
752
+ })
753
+ })
754
+
755
+ t .Run ("secret deleted" , func (t * testing.T ) {
756
+ runDetailedDiffTest (t , propertyMapWithSecrets , propertyMapProp2 , tfs , ps , map [string ]* pulumirpc.PropertyDiff {
757
+ "foo.prop1" : {Kind : pulumirpc .PropertyDiff_DELETE },
758
+ })
759
+ })
726
760
}
727
761
728
762
func TestDetailedDiffList (t * testing.T ) {
@@ -892,6 +926,22 @@ func TestDetailedDiffSet(t *testing.T) {
892
926
},
893
927
)
894
928
929
+ propertyMapWithSecrets := resource .NewPropertyMapFromMap (
930
+ map [string ]interface {}{
931
+ "foo" : []interface {}{resource .NewSecretProperty (
932
+ & resource.Secret {Element : resource .NewStringProperty ("val1" )}), "val2" },
933
+ },
934
+ )
935
+
936
+ propertyMapWithSecretsAndOutputs := resource .NewPropertyMapFromMap (
937
+ map [string ]interface {}{
938
+ "foo" : []interface {}{
939
+ resource .NewSecretProperty (& resource.Secret {Element : resource .NewStringProperty ("val1" )}),
940
+ resource .NewOutputProperty (resource.Output {Element : resource .NewStringProperty ("val2" )}),
941
+ },
942
+ },
943
+ )
944
+
895
945
t .Run ("unchanged" , func (t * testing.T ) {
896
946
runDetailedDiffTest (t , propertyMapVal1 , propertyMapVal1 , tfs , ps , map [string ]* pulumirpc.PropertyDiff {})
897
947
})
@@ -940,6 +990,38 @@ func TestDetailedDiffSet(t *testing.T) {
940
990
"foo[1]" : {Kind : pulumirpc .PropertyDiff_ADD },
941
991
})
942
992
})
993
+
994
+ t .Run ("secret added" , func (t * testing.T ) {
995
+ runDetailedDiffTest (t , propertyMapVal2 , propertyMapWithSecrets , tfs , ps , map [string ]* pulumirpc.PropertyDiff {
996
+ "foo[0]" : {Kind : pulumirpc .PropertyDiff_ADD },
997
+ })
998
+ })
999
+
1000
+ t .Run ("secret and output added" , func (t * testing.T ) {
1001
+ runDetailedDiffTest (
1002
+ t , propertyMapEmpty , propertyMapWithSecretsAndOutputs , tfs , ps , map [string ]* pulumirpc.PropertyDiff {
1003
+ "foo[0]" : {Kind : pulumirpc .PropertyDiff_ADD },
1004
+ "foo[1]" : {Kind : pulumirpc .PropertyDiff_ADD },
1005
+ })
1006
+ })
1007
+
1008
+ t .Run ("secret removed" , func (t * testing.T ) {
1009
+ runDetailedDiffTest (t , propertyMapWithSecrets , propertyMapVal2 , tfs , ps , map [string ]* pulumirpc.PropertyDiff {
1010
+ "foo[0]" : {Kind : pulumirpc .PropertyDiff_DELETE },
1011
+ })
1012
+ })
1013
+
1014
+ t .Run ("output removed" , func (t * testing.T ) {
1015
+ runDetailedDiffTest (t , propertyMapWithSecretsAndOutputs , propertyMapVal1 , tfs , ps , map [string ]* pulumirpc.PropertyDiff {
1016
+ "foo[1]" : {Kind : pulumirpc .PropertyDiff_DELETE },
1017
+ })
1018
+ })
1019
+
1020
+ t .Run ("secretness and outputness changed" , func (t * testing.T ) {
1021
+ runDetailedDiffTest (t , propertyMapWithSecretsAndOutputs , propertyMapBoth , tfs , ps , map [string ]* pulumirpc.PropertyDiff {
1022
+ "foo[1]" : {Kind : pulumirpc .PropertyDiff_UPDATE },
1023
+ })
1024
+ })
943
1025
}
944
1026
945
1027
func TestDetailedDiffTFForceNewPlain (t * testing.T ) {
0 commit comments