Skip to content

Commit

Permalink
Merge pull request #31 from dchudik/master
Browse files Browse the repository at this point in the history
Fix method UpdateZoneState. URL was incorrect.
  • Loading branch information
tarry-dvice authored Jan 25, 2024
2 parents 4796afa + 1de8583 commit 5d317a9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
9 changes: 5 additions & 4 deletions pkg/v2/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
9 changes: 5 additions & 4 deletions pkg/v2/testing/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
13 changes: 13 additions & 0 deletions pkg/v2/testing/zoneManager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion pkg/v2/zoneManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 5d317a9

Please sign in to comment.