diff --git a/pkg/v2/base.go b/pkg/v2/base.go index 370262a..edb7ab9 100644 --- a/pkg/v2/base.go +++ b/pkg/v2/base.go @@ -7,10 +7,11 @@ import ( ) const ( - rootPath = "/zones" - zonePath = "/zones/%v" - rrsetPath = "/zones/%v/rrset" - singleRRSetPath = "/zones/%v/rrset/%v" + rootPath = "/zones" + zonePath = "/zones/%v" + zonePathUpdateState = "/zones/%v/state" + rrsetPath = "/zones/%v/rrset" + singleRRSetPath = "/zones/%v/rrset/%v" ) type ( diff --git a/pkg/v2/testing/test_utils.go b/pkg/v2/testing/test_utils.go index f0195bf..ee6346c 100644 --- a/pkg/v2/testing/test_utils.go +++ b/pkg/v2/testing/test_utils.go @@ -17,10 +17,11 @@ const ( ) const ( - rootPath = "/zones" - zonePath = "/zones/%v" - rrsetPath = "/zones/%v/rrset" - singleRRSetPath = "/zones/%v/rrset/%v" + rootPath = "/zones" + zonePath = "/zones/%v" + zonePathUpdateState = "/zones/%v/state" + rrsetPath = "/zones/%v/rrset" + singleRRSetPath = "/zones/%v/rrset/%v" ) var ( diff --git a/pkg/v2/testing/zoneManager_test.go b/pkg/v2/testing/zoneManager_test.go index 6ffd0d9..9adc457 100644 --- a/pkg/v2/testing/zoneManager_test.go +++ b/pkg/v2/testing/zoneManager_test.go @@ -134,3 +134,16 @@ func (s *ZoneManageSuite) TestCreateZone_err_bad_request_with_description_and_lo expectedError := "error response: bad_request. Description: field required. Location: body.name." s.EqualValues(err.Error(), expectedError) } + +func (s *ZoneManageSuite) TestUpdateZoneState_state_updated() { + path := fmt.Sprintf(zonePathUpdateState, testID) + httpmock.RegisterResponder( + http.MethodPatch, + fmt.Sprintf("%s%s", testAPIURL, path), + httpmock.NewBytesResponder(http.StatusNoContent, []byte{}), + ) + + err := testClient.UpdateZoneState(testCtx, testID, true) + + s.Nil(err) +} diff --git a/pkg/v2/zoneManager.go b/pkg/v2/zoneManager.go index 2418548..a36d4b9 100644 --- a/pkg/v2/zoneManager.go +++ b/pkg/v2/zoneManager.go @@ -117,7 +117,7 @@ func (c *Client) UpdateZoneState(ctx context.Context, zoneID string, disabled bo } form := bytes.NewReader(updateState) r, e := c.prepareRequest( - ctx, http.MethodPatch, fmt.Sprintf(zonePath, zoneID), form, nil, nil, + ctx, http.MethodPatch, fmt.Sprintf(zonePathUpdateState, zoneID), form, nil, nil, ) _, err = processRequest[Zone](c.httpClient, r, e)