|
|
|
|
@ -16,7 +16,7 @@ func TestPathsWithMark(t *testing.T) {
|
|
|
|
|
input := []cty.PathValueMarks{
|
|
|
|
|
{
|
|
|
|
|
Path: cty.GetAttrPath("sensitive"),
|
|
|
|
|
Marks: cty.NewValueMarks(Sensitive),
|
|
|
|
|
Marks: cty.NewValueMarks("sensitive"),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Path: cty.GetAttrPath("other"),
|
|
|
|
|
@ -24,11 +24,15 @@ func TestPathsWithMark(t *testing.T) {
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Path: cty.GetAttrPath("both"),
|
|
|
|
|
Marks: cty.NewValueMarks(Sensitive, "other"),
|
|
|
|
|
Marks: cty.NewValueMarks("sensitive", "other"),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Path: cty.GetAttrPath("neither"),
|
|
|
|
|
Marks: cty.NewValueMarks("x", "y"),
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gotPaths, gotOthers := PathsWithMark(input, Sensitive)
|
|
|
|
|
gotPaths, gotOthers := PathsWithMark(input, "sensitive")
|
|
|
|
|
wantPaths := []cty.Path{
|
|
|
|
|
cty.GetAttrPath("sensitive"),
|
|
|
|
|
cty.GetAttrPath("both"),
|
|
|
|
|
@ -40,7 +44,7 @@ func TestPathsWithMark(t *testing.T) {
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Path: cty.GetAttrPath("both"),
|
|
|
|
|
Marks: cty.NewValueMarks(Sensitive, "other"),
|
|
|
|
|
Marks: cty.NewValueMarks("sensitive", "other"),
|
|
|
|
|
// Note that this intentionally preserves the fact that the
|
|
|
|
|
// attribute was both sensitive _and_ had another mark, since
|
|
|
|
|
// that gives the caller the most possible information to
|
|
|
|
|
@ -48,6 +52,10 @@ func TestPathsWithMark(t *testing.T) {
|
|
|
|
|
// an error message, or whatever. It also conveniently avoids
|
|
|
|
|
// allocating a new mark set, which is nice.
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Path: cty.GetAttrPath("neither"),
|
|
|
|
|
Marks: cty.NewValueMarks("x", "y"),
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if diff := cmp.Diff(wantPaths, gotPaths, ctydebug.CmpOptions); diff != "" {
|
|
|
|
|
@ -58,6 +66,40 @@ func TestPathsWithMark(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestRemoveAll(t *testing.T) {
|
|
|
|
|
input := []cty.PathValueMarks{
|
|
|
|
|
{
|
|
|
|
|
Path: cty.GetAttrPath("sensitive"),
|
|
|
|
|
Marks: cty.NewValueMarks("sensitive"),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Path: cty.GetAttrPath("other"),
|
|
|
|
|
Marks: cty.NewValueMarks("other"),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Path: cty.GetAttrPath("both"),
|
|
|
|
|
Marks: cty.NewValueMarks("sensitive", "other"),
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
want := []cty.PathValueMarks{
|
|
|
|
|
{
|
|
|
|
|
Path: cty.GetAttrPath("sensitive"),
|
|
|
|
|
Marks: cty.NewValueMarks("sensitive"),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Path: cty.GetAttrPath("both"),
|
|
|
|
|
Marks: cty.NewValueMarks("sensitive"),
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
got := RemoveAll(input, "other")
|
|
|
|
|
|
|
|
|
|
if diff := cmp.Diff(want, got, ctydebug.CmpOptions); diff != "" {
|
|
|
|
|
t.Errorf("wrong matched paths\n%s", diff)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestMarkPaths(t *testing.T) {
|
|
|
|
|
value := cty.ObjectVal(map[string]cty.Value{
|
|
|
|
|
"s": cty.StringVal(".s"),
|
|
|
|
|
|