@@ -137,6 +137,33 @@ func TestUpdateZone(t *testing.T) {
137
137
assert .Equal (t , expected , zone )
138
138
}
139
139
140
+ func TestUpdateZone_error (t * testing.T ) {
141
+ domain := "example.com"
142
+
143
+ client := setupTest (t , http .MethodPatch , "/v1/zones/" + domain , http .StatusUnauthorized , "error.json" )
144
+
145
+ patch := ZoneRequest {
146
+ Data : Zone {
147
+ Type : "zone" ,
148
+ ID : domain ,
149
+ Attributes : Attributes {
150
+ Records : map [string ]map [string ][]Record {
151
+ "_acme-challenge.test" : {
152
+ "TXT" : []Record {
153
+ {Data : "test" },
154
+ {Data : "test1" },
155
+ {Data : "test2" },
156
+ },
157
+ },
158
+ },
159
+ },
160
+ },
161
+ }
162
+
163
+ _ , err := client .UpdateZone (context .Background (), domain , patch )
164
+ require .EqualError (t , err , "could not update zone example.com: api error: status=401, message=Authentication Error" )
165
+ }
166
+
140
167
func TestGetZones (t * testing.T ) {
141
168
client := setupTest (t , http .MethodGet , "/v1/zones/" , http .StatusOK , "zones.json" )
142
169
@@ -171,6 +198,13 @@ func TestGetZones(t *testing.T) {
171
198
assert .Equal (t , expected , zones )
172
199
}
173
200
201
+ func TestGetZones_error (t * testing.T ) {
202
+ client := setupTest (t , http .MethodGet , "/v1/zones/" , http .StatusUnauthorized , "error.json" )
203
+
204
+ _ , err := client .GetZones (context .Background (), nil )
205
+ require .EqualError (t , err , "could not get zones: api error: status=401, message=Authentication Error" )
206
+ }
207
+
174
208
func TestGetZone (t * testing.T ) {
175
209
domain := "example.com"
176
210
@@ -227,3 +261,12 @@ func TestGetZone(t *testing.T) {
227
261
228
262
assert .Equal (t , expected , zones )
229
263
}
264
+
265
+ func TestGetZone_error (t * testing.T ) {
266
+ domain := "example.com"
267
+
268
+ client := setupTest (t , http .MethodGet , "/v1/zones/" + domain , http .StatusUnauthorized , "error.json" )
269
+
270
+ _ , err := client .GetZone (context .Background (), domain )
271
+ require .EqualError (t , err , "could not get zone example.com: api error: status=401, message=Authentication Error" )
272
+ }
0 commit comments