@@ -137,6 +137,33 @@ func TestUpdateZone(t *testing.T) {
137137 assert .Equal (t , expected , zone )
138138}
139139
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+
140167func TestGetZones (t * testing.T ) {
141168 client := setupTest (t , http .MethodGet , "/v1/zones/" , http .StatusOK , "zones.json" )
142169
@@ -171,6 +198,13 @@ func TestGetZones(t *testing.T) {
171198 assert .Equal (t , expected , zones )
172199}
173200
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+
174208func TestGetZone (t * testing.T ) {
175209 domain := "example.com"
176210
@@ -227,3 +261,12 @@ func TestGetZone(t *testing.T) {
227261
228262 assert .Equal (t , expected , zones )
229263}
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