@@ -322,6 +322,18 @@ func TestTest_Runs(t *testing.T) {
322
322
expectedErr : []string {"Cannot apply non-applyable plan" },
323
323
code : 1 ,
324
324
},
325
+ "write-only-attributes" : {
326
+ expectedOut : []string {"1 passed, 0 failed." },
327
+ code : 0 ,
328
+ },
329
+ "write-only-attributes-mocked" : {
330
+ expectedOut : []string {"1 passed, 0 failed." },
331
+ code : 0 ,
332
+ },
333
+ "write-only-attributes-overridden" : {
334
+ expectedOut : []string {"1 passed, 0 failed." },
335
+ code : 0 ,
336
+ },
325
337
}
326
338
for name , tc := range tcs {
327
339
t .Run (name , func (t * testing.T ) {
@@ -1618,6 +1630,7 @@ Terraform will perform the following actions:
1618
1630
+ destroy_fail = (known after apply)
1619
1631
+ id = "constant_value"
1620
1632
+ value = "bar"
1633
+ + write_only = (write-only attribute)
1621
1634
}
1622
1635
1623
1636
Plan: 1 to add, 0 to change, 0 to destroy.
@@ -1629,6 +1642,7 @@ resource "test_resource" "foo" {
1629
1642
destroy_fail = false
1630
1643
id = "constant_value"
1631
1644
value = "bar"
1645
+ write_only = (write-only attribute)
1632
1646
}
1633
1647
1634
1648
main.tftest.hcl... tearing down
@@ -1951,6 +1965,7 @@ resource "test_resource" "module_resource" {
1951
1965
destroy_fail = false
1952
1966
id = "df6h8as9"
1953
1967
value = "start"
1968
+ write_only = (write-only attribute)
1954
1969
}
1955
1970
1956
1971
run "initial_apply"... pass
@@ -1960,6 +1975,7 @@ resource "test_resource" "resource" {
1960
1975
destroy_fail = false
1961
1976
id = "598318e0"
1962
1977
value = "start"
1978
+ write_only = (write-only attribute)
1963
1979
}
1964
1980
1965
1981
run "plan_second_example"... pass
@@ -1975,6 +1991,7 @@ Terraform will perform the following actions:
1975
1991
+ destroy_fail = (known after apply)
1976
1992
+ id = "b6a1d8cb"
1977
1993
+ value = "start"
1994
+ + write_only = (write-only attribute)
1978
1995
}
1979
1996
1980
1997
Plan: 1 to add, 0 to change, 0 to destroy.
@@ -1991,7 +2008,7 @@ Terraform will perform the following actions:
1991
2008
~ resource "test_resource" "resource" {
1992
2009
id = "598318e0"
1993
2010
~ value = "start" -> "update"
1994
- # (1 unchanged attribute hidden)
2011
+ # (2 unchanged attributes hidden)
1995
2012
}
1996
2013
1997
2014
Plan: 0 to add, 1 to change, 0 to destroy.
@@ -2008,7 +2025,7 @@ Terraform will perform the following actions:
2008
2025
~ resource "test_resource" "module_resource" {
2009
2026
id = "df6h8as9"
2010
2027
~ value = "start" -> "update"
2011
- # (1 unchanged attribute hidden)
2028
+ # (2 unchanged attributes hidden)
2012
2029
}
2013
2030
2014
2031
Plan: 0 to add, 1 to change, 0 to destroy.
@@ -2021,8 +2038,8 @@ Success! 5 passed, 0 failed.
2021
2038
2022
2039
actual := output .All ()
2023
2040
2024
- if ! strings . Contains ( actual , expected ) {
2025
- t .Errorf ("output didn't match expected:\n expected:\n %s\n actual:\n %s" , expected , actual )
2041
+ if diff := cmp . Diff ( expected , actual ); diff != "" {
2042
+ t .Errorf ("output didn't match expected:\n expected:\n %s\n actual:\n %s\n diff: \n %s " , expected , actual , diff )
2026
2043
}
2027
2044
2028
2045
if provider .ResourceCount () > 0 {
@@ -2831,6 +2848,7 @@ resource "test_resource" "resource" {
2831
2848
destroy_fail = false
2832
2849
id = "9ddca5a9"
2833
2850
value = (sensitive value)
2851
+ write_only = (write-only attribute)
2834
2852
}
2835
2853
2836
2854
@@ -2845,6 +2863,7 @@ resource "test_resource" "resource" {
2845
2863
destroy_fail = false
2846
2864
id = "9ddca5a9"
2847
2865
value = (sensitive value)
2866
+ write_only = (write-only attribute)
2848
2867
}
2849
2868
2850
2869
0 commit comments