Skip to content

Commit 9ab41f8

Browse files
authored
Make the delete app version request synchronous (#44)
* Make the delete app version request synchronous
1 parent 548777a commit 9ab41f8

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

apptrust/http/http_client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type ApptrustHttpClient interface {
2626
Post(path string, requestBody interface{}, params map[string]string) (resp *http.Response, body []byte, err error)
2727
Get(path string) (resp *http.Response, body []byte, err error)
2828
Patch(path string, requestBody interface{}) (resp *http.Response, body []byte, err error)
29-
Delete(path string) (resp *http.Response, body []byte, err error)
29+
Delete(path string, params map[string]string) (resp *http.Response, body []byte, err error)
3030
}
3131

3232
type apptrustHttpClient struct {
@@ -139,8 +139,8 @@ func (c *apptrustHttpClient) toJsonBytes(payload interface{}) ([]byte, error) {
139139
return jsonBytes, nil
140140
}
141141

142-
func (c *apptrustHttpClient) Delete(path string) (resp *http.Response, body []byte, err error) {
143-
url, err := utils.BuildUrl(c.serverDetails.Url, apptrustApiPath+path, nil)
142+
func (c *apptrustHttpClient) Delete(path string, params map[string]string) (resp *http.Response, body []byte, err error) {
143+
url, err := utils.BuildUrl(c.serverDetails.Url, apptrustApiPath+path, params)
144144
if err != nil {
145145
return nil, nil, err
146146
}

apptrust/service/applications/application_service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func (as *applicationService) UpdateApplication(ctx service.Context, requestBody
6060

6161
func (as *applicationService) DeleteApplication(ctx service.Context, applicationKey string) error {
6262
endpoint := fmt.Sprintf("/v1/applications/%s", applicationKey)
63-
response, responseBody, err := ctx.GetHttpClient().Delete(endpoint)
63+
response, responseBody, err := ctx.GetHttpClient().Delete(endpoint, nil)
6464
if err != nil {
6565
return err
6666
}

apptrust/service/packages/package_service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (ps *packageService) BindPackage(ctx service.Context, applicationKey string
4242

4343
func (ps *packageService) UnbindPackage(ctx service.Context, applicationKey, pkgType, pkgName, pkgVersion string) error {
4444
endpoint := fmt.Sprintf("/v1/applications/%s/packages/%s/%s/%s", applicationKey, pkgType, url.PathEscape(pkgName), pkgVersion)
45-
response, responseBody, err := ctx.GetHttpClient().Delete(endpoint)
45+
response, responseBody, err := ctx.GetHttpClient().Delete(endpoint, nil)
4646
if err != nil {
4747
return err
4848
}

apptrust/service/packages/package_service_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func TestUnbindPackage(t *testing.T) {
141141
for _, tt := range tests {
142142
t.Run(tt.name, func(t *testing.T) {
143143
mockHttpClient := mockhttp.NewMockApptrustHttpClient(ctrl)
144-
mockHttpClient.EXPECT().Delete(fmt.Sprintf("/v1/applications/%s/packages/%s/%s/%s", applicationKey, tt.pkgType, url.PathEscape(tt.pkgName), tt.pkgVersion)).
144+
mockHttpClient.EXPECT().Delete(fmt.Sprintf("/v1/applications/%s/packages/%s/%s/%s", applicationKey, tt.pkgType, url.PathEscape(tt.pkgName), tt.pkgVersion), nil).
145145
Return(tt.mockResponse, []byte(""), tt.mockError).Times(1)
146146

147147
mockCtx := mockservice.NewMockContext(ctrl)

apptrust/service/versions/version_service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func (vs *versionService) RollbackAppVersion(ctx service.Context, applicationKey
101101

102102
func (vs *versionService) DeleteAppVersion(ctx service.Context, applicationKey, version string) error {
103103
url := fmt.Sprintf("/v1/applications/%s/versions/%s", applicationKey, version)
104-
response, responseBody, err := ctx.GetHttpClient().Delete(url)
104+
response, responseBody, err := ctx.GetHttpClient().Delete(url, map[string]string{"async": "false"})
105105
if err != nil {
106106
return err
107107
}

0 commit comments

Comments
 (0)