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