@@ -34,6 +34,40 @@ func TestDataGetAtPath(t *testing.T) {
34
34
expected any
35
35
expectedDiags diag.Diagnostics
36
36
}{
37
+ "invalid-path" : {
38
+ data : fwschemadata.Data {
39
+ Schema : testschema.Schema {
40
+ Attributes : map [string ]fwschema.Attribute {
41
+ "test" : testschema.Attribute {
42
+ Optional : true ,
43
+ Type : types .StringType ,
44
+ },
45
+ },
46
+ },
47
+ TerraformValue : tftypes .NewValue (
48
+ tftypes.Object {
49
+ AttributeTypes : map [string ]tftypes.Type {
50
+ "test" : tftypes .String ,
51
+ },
52
+ },
53
+ map [string ]tftypes.Value {
54
+ "test" : tftypes .NewValue (tftypes .String , "test-value" ),
55
+ },
56
+ ),
57
+ },
58
+ path : path .Root ("not-test" ),
59
+ target : new (string ),
60
+ expected : new (string ),
61
+ expectedDiags : diag.Diagnostics {
62
+ diag .NewAttributeErrorDiagnostic (
63
+ path .Root ("not-test" ),
64
+ "Data Read Error" ,
65
+ "An unexpected error was encountered trying to retrieve type information at a given path. " +
66
+ "This is always an error in the provider. Please report the following to the provider developer:\n \n " +
67
+ "Error: AttributeName(\" not-test\" ) still remains in the path: could not find attribute or block \" not-test\" in schema" ,
68
+ ),
69
+ },
70
+ },
37
71
"invalid-target" : {
38
72
data : fwschemadata.Data {
39
73
Schema : testschema.Schema {
@@ -104,6 +138,29 @@ func TestDataGetAtPath(t *testing.T) {
104
138
),
105
139
},
106
140
},
141
+ "TerraformValue-null" : {
142
+ data : fwschemadata.Data {
143
+ Schema : testschema.Schema {
144
+ Attributes : map [string ]fwschema.Attribute {
145
+ "test" : testschema.Attribute {
146
+ Optional : true ,
147
+ Type : types .StringType ,
148
+ },
149
+ },
150
+ },
151
+ TerraformValue : tftypes .NewValue (
152
+ tftypes.Object {
153
+ AttributeTypes : map [string ]tftypes.Type {
154
+ "test" : tftypes .String ,
155
+ },
156
+ },
157
+ nil ,
158
+ ),
159
+ },
160
+ path : path .Root ("test" ),
161
+ target : new (types.String ),
162
+ expected : pointer (types .StringNull ()),
163
+ },
107
164
"AttrTypeWithValidateError" : {
108
165
data : fwschemadata.Data {
109
166
Schema : testschema.Schema {
0 commit comments