@@ -16,19 +16,23 @@ func TestPathsWithMark(t *testing.T) {
1616 input := []cty.PathValueMarks {
1717 {
1818 Path : cty .GetAttrPath ("sensitive" ),
19- Marks : cty .NewValueMarks (Sensitive ),
19+ Marks : cty .NewValueMarks ("sensitive" ),
2020 },
2121 {
2222 Path : cty .GetAttrPath ("other" ),
2323 Marks : cty .NewValueMarks ("other" ),
2424 },
2525 {
2626 Path : cty .GetAttrPath ("both" ),
27- Marks : cty .NewValueMarks (Sensitive , "other" ),
27+ Marks : cty .NewValueMarks ("sensitive" , "other" ),
28+ },
29+ {
30+ Path : cty .GetAttrPath ("neither" ),
31+ Marks : cty .NewValueMarks ("x" , "y" ),
2832 },
2933 }
3034
31- gotPaths , gotOthers := PathsWithMark (input , Sensitive )
35+ gotPaths , gotOthers := PathsWithMark (input , "sensitive" )
3236 wantPaths := []cty.Path {
3337 cty .GetAttrPath ("sensitive" ),
3438 cty .GetAttrPath ("both" ),
@@ -40,14 +44,18 @@ func TestPathsWithMark(t *testing.T) {
4044 },
4145 {
4246 Path : cty .GetAttrPath ("both" ),
43- Marks : cty .NewValueMarks (Sensitive , "other" ),
47+ Marks : cty .NewValueMarks ("sensitive" , "other" ),
4448 // Note that this intentionally preserves the fact that the
4549 // attribute was both sensitive _and_ had another mark, since
4650 // that gives the caller the most possible information to
4751 // potentially handle this combination in a special way in
4852 // an error message, or whatever. It also conveniently avoids
4953 // allocating a new mark set, which is nice.
5054 },
55+ {
56+ Path : cty .GetAttrPath ("neither" ),
57+ Marks : cty .NewValueMarks ("x" , "y" ),
58+ },
5159 }
5260
5361 if diff := cmp .Diff (wantPaths , gotPaths , ctydebug .CmpOptions ); diff != "" {
@@ -58,6 +66,40 @@ func TestPathsWithMark(t *testing.T) {
5866 }
5967}
6068
69+ func TestRemoveAll (t * testing.T ) {
70+ input := []cty.PathValueMarks {
71+ {
72+ Path : cty .GetAttrPath ("sensitive" ),
73+ Marks : cty .NewValueMarks ("sensitive" ),
74+ },
75+ {
76+ Path : cty .GetAttrPath ("other" ),
77+ Marks : cty .NewValueMarks ("other" ),
78+ },
79+ {
80+ Path : cty .GetAttrPath ("both" ),
81+ Marks : cty .NewValueMarks ("sensitive" , "other" ),
82+ },
83+ }
84+
85+ want := []cty.PathValueMarks {
86+ {
87+ Path : cty .GetAttrPath ("sensitive" ),
88+ Marks : cty .NewValueMarks ("sensitive" ),
89+ },
90+ {
91+ Path : cty .GetAttrPath ("both" ),
92+ Marks : cty .NewValueMarks ("sensitive" ),
93+ },
94+ }
95+
96+ got := RemoveAll (input , "other" )
97+
98+ if diff := cmp .Diff (want , got , ctydebug .CmpOptions ); diff != "" {
99+ t .Errorf ("wrong matched paths\n %s" , diff )
100+ }
101+ }
102+
61103func TestMarkPaths (t * testing.T ) {
62104 value := cty .ObjectVal (map [string ]cty.Value {
63105 "s" : cty .StringVal (".s" ),
0 commit comments