@@ -20,6 +20,7 @@ import (
20
20
"fmt"
21
21
"hash/crc32"
22
22
"slices"
23
+ "strconv"
23
24
"strings"
24
25
"testing"
25
26
@@ -1625,6 +1626,14 @@ func TestBlockCollectionElementForceNew(t *testing.T) {
1625
1626
})
1626
1627
}
1627
1628
1629
+ type diffTestOutput struct {
1630
+ initialValue cty.Value
1631
+ changeValue cty.Value
1632
+ tfOut string
1633
+ pulumiOut string
1634
+ detailedDiff map [string ]any
1635
+ }
1636
+
1628
1637
func TestDetailedDiffReplacementComputedProperty (t * testing.T ) {
1629
1638
t .Parallel ()
1630
1639
@@ -1649,14 +1658,6 @@ func TestDetailedDiffReplacementComputedProperty(t *testing.T) {
1649
1658
},
1650
1659
}
1651
1660
1652
- type testOutput struct {
1653
- initialValue cty.Value
1654
- changeValue cty.Value
1655
- tfOut string
1656
- pulumiOut string
1657
- detailedDiff map [string ]any
1658
- }
1659
-
1660
1661
t .Run ("no change" , func (t * testing.T ) {
1661
1662
t .Parallel ()
1662
1663
initialValue := cty .ObjectVal (map [string ]cty.Value {})
@@ -1667,7 +1668,7 @@ func TestDetailedDiffReplacementComputedProperty(t *testing.T) {
1667
1668
Config2 : changeValue ,
1668
1669
})
1669
1670
1670
- autogold .ExpectFile (t , testOutput {
1671
+ autogold .ExpectFile (t , diffTestOutput {
1671
1672
initialValue : initialValue ,
1672
1673
changeValue : changeValue ,
1673
1674
tfOut : diff .TFOut ,
@@ -1686,7 +1687,7 @@ func TestDetailedDiffReplacementComputedProperty(t *testing.T) {
1686
1687
Config2 : changeValue ,
1687
1688
})
1688
1689
1689
- autogold .ExpectFile (t , testOutput {
1690
+ autogold .ExpectFile (t , diffTestOutput {
1690
1691
initialValue : initialValue ,
1691
1692
changeValue : changeValue ,
1692
1693
tfOut : diff .TFOut ,
@@ -1705,7 +1706,7 @@ func TestDetailedDiffReplacementComputedProperty(t *testing.T) {
1705
1706
Config2 : changeValue ,
1706
1707
})
1707
1708
1708
- autogold .ExpectFile (t , testOutput {
1709
+ autogold .ExpectFile (t , diffTestOutput {
1709
1710
initialValue : initialValue ,
1710
1711
changeValue : changeValue ,
1711
1712
tfOut : diff .TFOut ,
@@ -1724,7 +1725,7 @@ func TestDetailedDiffReplacementComputedProperty(t *testing.T) {
1724
1725
Config2 : changeValue ,
1725
1726
})
1726
1727
1727
- autogold .ExpectFile (t , testOutput {
1728
+ autogold .ExpectFile (t , diffTestOutput {
1728
1729
initialValue : initialValue ,
1729
1730
changeValue : changeValue ,
1730
1731
tfOut : diff .TFOut ,
@@ -1733,3 +1734,112 @@ func TestDetailedDiffReplacementComputedProperty(t *testing.T) {
1733
1734
})
1734
1735
})
1735
1736
}
1737
+
1738
+ func TestPropertyWithDot (t * testing.T ) {
1739
+ res := & schema.Resource {
1740
+ Schema : map [string ]* schema.Schema {
1741
+ "prop" : {
1742
+ Type : schema .TypeList ,
1743
+ Optional : true ,
1744
+ MaxItems : 1 ,
1745
+ Elem : & schema.Resource {
1746
+ Schema : map [string ]* schema.Schema {
1747
+ "foo" : {
1748
+ Type : schema .TypeString ,
1749
+ Optional : true ,
1750
+ },
1751
+ },
1752
+ },
1753
+ },
1754
+ },
1755
+ }
1756
+
1757
+ for _ , accuratePreivewsEnabled := range []bool {true , false } {
1758
+ t .Run (fmt .Sprintf ("accuratePreivewsEnabled=%v" , accuratePreivewsEnabled ), func (t * testing.T ) {
1759
+ t .Setenv ("PULUMI_TF_BRIDGE_ACCURATE_BRIDGE_PREVIEW" , strconv .FormatBool (accuratePreivewsEnabled ))
1760
+ t .Run ("unchanged" , func (t * testing.T ) {
1761
+ initialValue := cty .ObjectVal (map [string ]cty.Value {
1762
+ "prop" : cty .ListVal ([]cty.Value {
1763
+ cty .ObjectVal (map [string ]cty.Value {"foo.bar" : cty .StringVal ("baz" )}),
1764
+ }),
1765
+ })
1766
+ changeValue := cty .ObjectVal (map [string ]cty.Value {
1767
+ "prop" : cty .ListVal ([]cty.Value {
1768
+ cty .ObjectVal (map [string ]cty.Value {"foo.bar" : cty .StringVal ("baz" )}),
1769
+ }),
1770
+ })
1771
+ diff := runDiffCheck (t , diffTestCase {
1772
+ Resource : res ,
1773
+ Config1 : initialValue ,
1774
+ Config2 : changeValue ,
1775
+ })
1776
+
1777
+ autogold .ExpectFile (t , diffTestOutput {
1778
+ initialValue : initialValue ,
1779
+ changeValue : changeValue ,
1780
+ tfOut : diff .TFOut ,
1781
+ pulumiOut : diff .PulumiOut ,
1782
+ detailedDiff : diff .PulumiDiff .DetailedDiff ,
1783
+ })
1784
+ })
1785
+
1786
+ t .Run ("added" , func (t * testing.T ) {
1787
+ initialValue := cty .ObjectVal (map [string ]cty.Value {
1788
+ "prop" : cty .ListVal ([]cty.Value {
1789
+ cty .ObjectVal (map [string ]cty.Value {"foo" : cty .StringVal ("bar" )}),
1790
+ }),
1791
+ })
1792
+ changeValue := cty .ObjectVal (map [string ]cty.Value {
1793
+ "prop" : cty .ListVal ([]cty.Value {
1794
+ cty .ObjectVal (map [string ]cty.Value {
1795
+ "foo" : cty .StringVal ("bar" ),
1796
+ "foo.bar" : cty .StringVal ("baz" ),
1797
+ }),
1798
+ }),
1799
+ })
1800
+ diff := runDiffCheck (t , diffTestCase {
1801
+ Resource : res ,
1802
+ Config1 : initialValue ,
1803
+ Config2 : changeValue ,
1804
+ })
1805
+
1806
+ autogold .ExpectFile (t , diffTestOutput {
1807
+ initialValue : initialValue ,
1808
+ changeValue : changeValue ,
1809
+ tfOut : diff .TFOut ,
1810
+ pulumiOut : diff .PulumiOut ,
1811
+ detailedDiff : diff .PulumiDiff .DetailedDiff ,
1812
+ })
1813
+ })
1814
+
1815
+ t .Run ("deleted" , func (t * testing.T ) {
1816
+ initialValue := cty .ObjectVal (map [string ]cty.Value {
1817
+ "prop" : cty .ListVal ([]cty.Value {
1818
+ cty .ObjectVal (map [string ]cty.Value {
1819
+ "foo" : cty .StringVal ("bar" ),
1820
+ "foo.bar" : cty .StringVal ("baz" ),
1821
+ }),
1822
+ }),
1823
+ })
1824
+ changeValue := cty .ObjectVal (map [string ]cty.Value {
1825
+ "prop" : cty .ListVal ([]cty.Value {
1826
+ cty .ObjectVal (map [string ]cty.Value {"foo" : cty .StringVal ("bar" )}),
1827
+ }),
1828
+ })
1829
+ diff := runDiffCheck (t , diffTestCase {
1830
+ Resource : res ,
1831
+ Config1 : initialValue ,
1832
+ Config2 : changeValue ,
1833
+ })
1834
+
1835
+ autogold .ExpectFile (t , diffTestOutput {
1836
+ initialValue : initialValue ,
1837
+ changeValue : changeValue ,
1838
+ tfOut : diff .TFOut ,
1839
+ pulumiOut : diff .PulumiOut ,
1840
+ detailedDiff : diff .PulumiDiff .DetailedDiff ,
1841
+ })
1842
+ })
1843
+ })
1844
+ }
1845
+ }
0 commit comments