55 "testing"
66
77 "github.com/hashicorp/terraform-plugin-framework/attr"
8+ "github.com/hashicorp/terraform-plugin-framework/path"
89 "github.com/hashicorp/terraform-plugin-framework/tfsdk"
910 "github.com/hashicorp/terraform-plugin-framework/types"
1011 "github.com/hashicorp/terraform-plugin-go/tftypes"
@@ -15,7 +16,7 @@ func TestAtLeastSumOfValidator(t *testing.T) {
1516
1617 type testCase struct {
1718 val attr.Value
18- attributesToSumPaths []* tftypes. AttributePath
19+ attributesToSumPaths []path. Path
1920 requestConfigRaw map [string ]tftypes.Value
2021 expectError bool
2122 }
@@ -32,9 +33,9 @@ func TestAtLeastSumOfValidator(t *testing.T) {
3233 },
3334 "valid integer as Int64 less than sum of attributes" : {
3435 val : types.Int64 {Value : 10 },
35- attributesToSumPaths : []* tftypes. AttributePath {
36- tftypes . NewAttributePath (). WithAttributeName ("one" ),
37- tftypes . NewAttributePath (). WithAttributeName ("two" ),
36+ attributesToSumPaths : []path. Path {
37+ path . Root ("one" ),
38+ path . Root ("two" ),
3839 },
3940 requestConfigRaw : map [string ]tftypes.Value {
4041 "one" : tftypes .NewValue (tftypes .Number , 15 ),
@@ -44,9 +45,9 @@ func TestAtLeastSumOfValidator(t *testing.T) {
4445 },
4546 "valid integer as Int64 equal to sum of attributes" : {
4647 val : types.Int64 {Value : 10 },
47- attributesToSumPaths : []* tftypes. AttributePath {
48- tftypes . NewAttributePath (). WithAttributeName ("one" ),
49- tftypes . NewAttributePath (). WithAttributeName ("two" ),
48+ attributesToSumPaths : []path. Path {
49+ path . Root ("one" ),
50+ path . Root ("two" ),
5051 },
5152 requestConfigRaw : map [string ]tftypes.Value {
5253 "one" : tftypes .NewValue (tftypes .Number , 5 ),
@@ -55,9 +56,9 @@ func TestAtLeastSumOfValidator(t *testing.T) {
5556 },
5657 "valid integer as Int64 greater than sum of attributes" : {
5758 val : types.Int64 {Value : 10 },
58- attributesToSumPaths : []* tftypes. AttributePath {
59- tftypes . NewAttributePath (). WithAttributeName ("one" ),
60- tftypes . NewAttributePath (). WithAttributeName ("two" ),
59+ attributesToSumPaths : []path. Path {
60+ path . Root ("one" ),
61+ path . Root ("two" ),
6162 },
6263 requestConfigRaw : map [string ]tftypes.Value {
6364 "one" : tftypes .NewValue (tftypes .Number , 4 ),
@@ -66,9 +67,9 @@ func TestAtLeastSumOfValidator(t *testing.T) {
6667 },
6768 "valid integer as Int64 greater than sum of attributes, when one summed attribute is null" : {
6869 val : types.Int64 {Value : 10 },
69- attributesToSumPaths : []* tftypes. AttributePath {
70- tftypes . NewAttributePath (). WithAttributeName ("one" ),
71- tftypes . NewAttributePath (). WithAttributeName ("two" ),
70+ attributesToSumPaths : []path. Path {
71+ path . Root ("one" ),
72+ path . Root ("two" ),
7273 },
7374 requestConfigRaw : map [string ]tftypes.Value {
7475 "one" : tftypes .NewValue (tftypes .Number , nil ),
@@ -77,9 +78,9 @@ func TestAtLeastSumOfValidator(t *testing.T) {
7778 },
7879 "valid integer as Int64 does not return error when all attributes are null" : {
7980 val : types.Int64 {Null : true },
80- attributesToSumPaths : []* tftypes. AttributePath {
81- tftypes . NewAttributePath (). WithAttributeName ("one" ),
82- tftypes . NewAttributePath (). WithAttributeName ("two" ),
81+ attributesToSumPaths : []path. Path {
82+ path . Root ("one" ),
83+ path . Root ("two" ),
8384 },
8485 requestConfigRaw : map [string ]tftypes.Value {
8586 "one" : tftypes .NewValue (tftypes .Number , nil ),
@@ -88,9 +89,9 @@ func TestAtLeastSumOfValidator(t *testing.T) {
8889 },
8990 "valid integer as Int64 returns error when all attributes to sum are null" : {
9091 val : types.Int64 {Value : - 1 },
91- attributesToSumPaths : []* tftypes. AttributePath {
92- tftypes . NewAttributePath (). WithAttributeName ("one" ),
93- tftypes . NewAttributePath (). WithAttributeName ("two" ),
92+ attributesToSumPaths : []path. Path {
93+ path . Root ("one" ),
94+ path . Root ("two" ),
9495 },
9596 requestConfigRaw : map [string ]tftypes.Value {
9697 "one" : tftypes .NewValue (tftypes .Number , nil ),
@@ -100,9 +101,9 @@ func TestAtLeastSumOfValidator(t *testing.T) {
100101 },
101102 "valid integer as Int64 greater than sum of attributes, when one summed attribute is unknown" : {
102103 val : types.Int64 {Value : 10 },
103- attributesToSumPaths : []* tftypes. AttributePath {
104- tftypes . NewAttributePath (). WithAttributeName ("one" ),
105- tftypes . NewAttributePath (). WithAttributeName ("two" ),
104+ attributesToSumPaths : []path. Path {
105+ path . Root ("one" ),
106+ path . Root ("two" ),
106107 },
107108 requestConfigRaw : map [string ]tftypes.Value {
108109 "one" : tftypes .NewValue (tftypes .Number , tftypes .UnknownValue ),
@@ -111,9 +112,9 @@ func TestAtLeastSumOfValidator(t *testing.T) {
111112 },
112113 "valid integer as Int64 does not return error when all attributes are unknown" : {
113114 val : types.Int64 {Unknown : true },
114- attributesToSumPaths : []* tftypes. AttributePath {
115- tftypes . NewAttributePath (). WithAttributeName ("one" ),
116- tftypes . NewAttributePath (). WithAttributeName ("two" ),
115+ attributesToSumPaths : []path. Path {
116+ path . Root ("one" ),
117+ path . Root ("two" ),
117118 },
118119 requestConfigRaw : map [string ]tftypes.Value {
119120 "one" : tftypes .NewValue (tftypes .Number , tftypes .UnknownValue ),
@@ -122,9 +123,9 @@ func TestAtLeastSumOfValidator(t *testing.T) {
122123 },
123124 "valid integer as Int64 does not return error when all attributes to sum are unknown" : {
124125 val : types.Int64 {Value : - 1 },
125- attributesToSumPaths : []* tftypes. AttributePath {
126- tftypes . NewAttributePath (). WithAttributeName ("one" ),
127- tftypes . NewAttributePath (). WithAttributeName ("two" ),
126+ attributesToSumPaths : []path. Path {
127+ path . Root ("one" ),
128+ path . Root ("two" ),
128129 },
129130 requestConfigRaw : map [string ]tftypes.Value {
130131 "one" : tftypes .NewValue (tftypes .Number , tftypes .UnknownValue ),
@@ -133,9 +134,9 @@ func TestAtLeastSumOfValidator(t *testing.T) {
133134 },
134135 "error when attribute to sum is not Number" : {
135136 val : types.Int64 {Value : 9 },
136- attributesToSumPaths : []* tftypes. AttributePath {
137- tftypes . NewAttributePath (). WithAttributeName ("one" ),
138- tftypes . NewAttributePath (). WithAttributeName ("two" ),
137+ attributesToSumPaths : []path. Path {
138+ path . Root ("one" ),
139+ path . Root ("two" ),
139140 },
140141 requestConfigRaw : map [string ]tftypes.Value {
141142 "one" : tftypes .NewValue (tftypes .Bool , true ),
@@ -149,7 +150,7 @@ func TestAtLeastSumOfValidator(t *testing.T) {
149150 name , test := name , test
150151 t .Run (name , func (t * testing.T ) {
151152 request := tfsdk.ValidateAttributeRequest {
152- AttributePath : tftypes . NewAttributePath (). WithAttributeName ("test" ),
153+ AttributePath : path . Root ("test" ),
153154 AttributeConfig : test .val ,
154155 Config : tfsdk.Config {
155156 Raw : tftypes .NewValue (tftypes.Object {}, test .requestConfigRaw ),
0 commit comments