Skip to content

Commit ccad28f

Browse files
Add new APIErrorBody struct and update deps (databricks#3745)
1 parent 9c9bf2b commit ccad28f

File tree

53 files changed

+285
-258
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+285
-258
lines changed

access/resource_ip_access_list_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"net/http"
99
"testing"
1010

11-
"github.com/databricks/databricks-sdk-go/apierr"
1211
"github.com/databricks/databricks-sdk-go/service/settings"
12+
"github.com/databricks/terraform-provider-databricks/common"
1313
"github.com/databricks/terraform-provider-databricks/qa"
1414

1515
"github.com/stretchr/testify/assert"
@@ -93,7 +93,7 @@ func TestAPIACLCreate_Error(t *testing.T) {
9393
{
9494
Method: http.MethodPost,
9595
Resource: "/api/2.0/ip-access-lists",
96-
Response: apierr.APIErrorBody{
96+
Response: common.APIErrorBody{
9797
ErrorCode: "RESOURCE_ALREADY_EXISTS",
9898
Message: "IP access list with type (" + TestingListTypeString + ") and label (" + TestingLabel + ") already exists",
9999
},
@@ -185,7 +185,7 @@ func TestIPACLUpdate_Error(t *testing.T) {
185185
ExpectedRequest: settings.UpdateIpAccessList{
186186
Enabled: TestingEnabled,
187187
},
188-
Response: apierr.APIErrorBody{
188+
Response: common.APIErrorBody{
189189
ErrorCode: "SERVER_ERROR",
190190
Message: "Something unexpected happened",
191191
},
@@ -240,7 +240,7 @@ func TestIPACLRead_NotFound(t *testing.T) {
240240
{
241241
Method: http.MethodGet,
242242
Resource: "/api/2.0/ip-access-lists/" + TestingId + "?",
243-
Response: apierr.APIErrorBody{
243+
Response: common.APIErrorBody{
244244
ErrorCode: "RESOURCE_DOES_NOT_EXIST",
245245
Message: "Can't find an IP access list with id: " + TestingId + ".",
246246
},
@@ -260,7 +260,7 @@ func TestIPACLRead_Error(t *testing.T) {
260260
{
261261
Method: http.MethodGet,
262262
Resource: "/api/2.0/ip-access-lists/" + TestingId + "?",
263-
Response: apierr.APIErrorBody{
263+
Response: common.APIErrorBody{
264264
ErrorCode: "SERVER_ERROR",
265265
Message: "Something unexpected happened",
266266
},
@@ -298,7 +298,7 @@ func TestIPACLDelete_Error(t *testing.T) {
298298
{
299299
Method: http.MethodDelete,
300300
Resource: fmt.Sprintf("/api/2.0/ip-access-lists/%s?", TestingId),
301-
Response: apierr.APIErrorBody{
301+
Response: common.APIErrorBody{
302302
ErrorCode: "INVALID_STATE",
303303
Message: "Something went wrong",
304304
},

aws/resource_group_instance_profile_test.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package aws
33
import (
44
"testing"
55

6-
"github.com/databricks/databricks-sdk-go/apierr"
6+
"github.com/databricks/terraform-provider-databricks/common"
77
"github.com/databricks/terraform-provider-databricks/scim"
88

99
"github.com/databricks/terraform-provider-databricks/qa"
@@ -56,7 +56,7 @@ func TestResourceGroupInstanceProfileCreate_Error(t *testing.T) {
5656
{
5757
Method: "PATCH",
5858
Resource: "/api/2.0/preview/scim/v2/Groups/abc",
59-
Response: apierr.APIErrorBody{
59+
Response: common.APIErrorBody{
6060
ErrorCode: "INVALID_REQUEST",
6161
Message: "Internal error happened",
6262
},
@@ -80,7 +80,7 @@ func TestResourceGroupInstanceProfileCreate_Error_InvalidARN(t *testing.T) {
8080
{
8181
Method: "PATCH",
8282
Resource: "/api/2.0/preview/scim/v2/Groups/abc",
83-
Response: apierr.APIErrorBody{
83+
Response: common.APIErrorBody{
8484
ErrorCode: "INVALID_REQUEST",
8585
Message: "Internal error happened",
8686
},
@@ -103,7 +103,7 @@ func TestResourceGroupInstanceProfileCreate_Error_OtherARN(t *testing.T) {
103103
{
104104
Method: "PATCH",
105105
Resource: "/api/2.0/preview/scim/v2/Groups/abc",
106-
Response: apierr.APIErrorBody{
106+
Response: common.APIErrorBody{
107107
ErrorCode: "INVALID_REQUEST",
108108
Message: "Internal error happened",
109109
},
@@ -152,7 +152,7 @@ func TestResourceGroupInstanceProfileRead_NotFound(t *testing.T) {
152152
{
153153
Method: "GET",
154154
Resource: "/api/2.0/preview/scim/v2/Groups/abc?attributes=roles",
155-
Response: apierr.APIErrorBody{
155+
Response: common.APIErrorBody{
156156
ErrorCode: "NOT_FOUND",
157157
Message: "Item not found",
158158
},
@@ -192,7 +192,7 @@ func TestResourceGroupInstanceProfileRead_Error(t *testing.T) {
192192
{
193193
Method: "GET",
194194
Resource: "/api/2.0/preview/scim/v2/Groups/abc?attributes=roles",
195-
Response: apierr.APIErrorBody{
195+
Response: common.APIErrorBody{
196196
ErrorCode: "INVALID_REQUEST",
197197
Message: "Internal error happened",
198198
},
@@ -232,7 +232,7 @@ func TestResourceGroupInstanceProfileDelete_Error(t *testing.T) {
232232
{
233233
Method: "PATCH",
234234
Resource: "/api/2.0/preview/scim/v2/Groups/abc",
235-
Response: apierr.APIErrorBody{
235+
Response: common.APIErrorBody{
236236
ErrorCode: "INVALID_REQUEST",
237237
Message: "Internal error happened",
238238
},

aws/resource_instance_profile_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package aws
33
import (
44
"testing"
55

6-
"github.com/databricks/databricks-sdk-go/apierr"
6+
"github.com/databricks/terraform-provider-databricks/common"
77
"github.com/databricks/terraform-provider-databricks/qa"
88

99
"github.com/stretchr/testify/assert"
@@ -114,7 +114,7 @@ func TestResourceInstanceProfileCreate_Error(t *testing.T) {
114114
{
115115
Method: "POST",
116116
Resource: "/api/2.0/instance-profiles/add",
117-
Response: apierr.APIErrorBody{
117+
Response: common.APIErrorBody{
118118
ErrorCode: "INVALID_REQUEST",
119119
Message: "Internal error happened",
120120
},
@@ -249,7 +249,7 @@ func TestResourceInstanceProfileRead_Error(t *testing.T) {
249249
{
250250
Method: "GET",
251251
Resource: "/api/2.0/instance-profiles/list",
252-
Response: apierr.APIErrorBody{
252+
Response: common.APIErrorBody{
253253
ErrorCode: "INVALID_REQUEST",
254254
Message: "Internal error happened",
255255
},
@@ -289,7 +289,7 @@ func TestResourceInstanceProfileDelete_Error(t *testing.T) {
289289
{
290290
Method: "POST",
291291
Resource: "/api/2.0/instance-profiles/remove",
292-
Response: apierr.APIErrorBody{
292+
Response: common.APIErrorBody{
293293
ErrorCode: "INVALID_REQUEST",
294294
Message: "Internal error happened",
295295
},
@@ -356,7 +356,7 @@ func TestResourceInstanceProfileUpdate_Error(t *testing.T) {
356356
{
357357
Method: "POST",
358358
Resource: "/api/2.0/instance-profiles/edit",
359-
Response: apierr.APIErrorBody{
359+
Response: common.APIErrorBody{
360360
ErrorCode: "INVALID_REQUEST",
361361
Message: "Internal error happened",
362362
},

aws/resource_service_principal_role_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package aws
33
import (
44
"testing"
55

6-
"github.com/databricks/databricks-sdk-go/apierr"
6+
"github.com/databricks/terraform-provider-databricks/common"
77
"github.com/databricks/terraform-provider-databricks/scim"
88

99
"github.com/databricks/terraform-provider-databricks/qa"
@@ -53,7 +53,7 @@ func TestResourceServicePrincipalRoleCreate_Error(t *testing.T) {
5353
{
5454
Method: "PATCH",
5555
Resource: "/api/2.0/preview/scim/v2/ServicePrincipals/abc",
56-
Response: apierr.APIErrorBody{
56+
Response: common.APIErrorBody{
5757
ErrorCode: "INVALID_REQUEST",
5858
Message: "Internal error happened",
5959
},
@@ -119,7 +119,7 @@ func TestResourceServicePrincipalRoleRead_NotFound(t *testing.T) {
119119
{
120120
Method: "GET",
121121
Resource: "/api/2.0/preview/scim/v2/ServicePrincipals/abc?attributes=roles",
122-
Response: apierr.APIErrorBody{
122+
Response: common.APIErrorBody{
123123
ErrorCode: "NOT_FOUND",
124124
Message: "Item not found",
125125
},

aws/resource_user_instance_profile_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package aws
33
import (
44
"testing"
55

6-
"github.com/databricks/databricks-sdk-go/apierr"
6+
"github.com/databricks/terraform-provider-databricks/common"
77
"github.com/databricks/terraform-provider-databricks/scim"
88

99
"github.com/databricks/terraform-provider-databricks/qa"
@@ -68,7 +68,7 @@ func TestResourceUserInstanceProfileCreate_Error(t *testing.T) {
6868
{
6969
Method: "PATCH",
7070
Resource: "/api/2.0/preview/scim/v2/Users/abc",
71-
Response: apierr.APIErrorBody{
71+
Response: common.APIErrorBody{
7272
ErrorCode: "INVALID_REQUEST",
7373
Message: "Internal error happened",
7474
},
@@ -138,7 +138,7 @@ func TestResourceUserInstanceProfileRead_NotFound(t *testing.T) {
138138
{
139139
Method: "GET",
140140
Resource: "/api/2.0/preview/scim/v2/Users/abc?attributes=roles",
141-
Response: apierr.APIErrorBody{
141+
Response: common.APIErrorBody{
142142
ErrorCode: "NOT_FOUND",
143143
Message: "Item not found",
144144
},
@@ -158,7 +158,7 @@ func TestResourceUserInstanceProfileRead_Error(t *testing.T) {
158158
{
159159
Method: "GET",
160160
Resource: "/api/2.0/preview/scim/v2/Users/abc?attributes=roles",
161-
Response: apierr.APIErrorBody{
161+
Response: common.APIErrorBody{
162162
ErrorCode: "INVALID_REQUEST",
163163
Message: "Internal error happened",
164164
},
@@ -198,7 +198,7 @@ func TestResourceUserInstanceProfileDelete_Error(t *testing.T) {
198198
{
199199
Method: "PATCH",
200200
Resource: "/api/2.0/preview/scim/v2/Users/abc",
201-
Response: apierr.APIErrorBody{
201+
Response: common.APIErrorBody{
202202
ErrorCode: "INVALID_REQUEST",
203203
Message: "Internal error happened",
204204
},

catalog/resource_artifact_allowlist_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"net/http"
55
"testing"
66

7-
"github.com/databricks/databricks-sdk-go/apierr"
87
"github.com/databricks/databricks-sdk-go/service/catalog"
8+
"github.com/databricks/terraform-provider-databricks/common"
99
"github.com/databricks/terraform-provider-databricks/qa"
1010
"github.com/stretchr/testify/assert"
1111
)
@@ -105,7 +105,7 @@ func TestArtifactAllowlistCreate_Error(t *testing.T) {
105105
Method: http.MethodPut,
106106
Resource: "/api/2.1/unity-catalog/artifact-allowlists/INIT_SCRIPT",
107107
ExpectedRequest: setArtifact,
108-
Response: apierr.APIErrorBody{
108+
Response: common.APIErrorBody{
109109
ErrorCode: "SERVER_ERROR",
110110
Message: "Something unexpected happened",
111111
},
@@ -156,7 +156,7 @@ func TestResourceArtifactAllowlistRead_Error(t *testing.T) {
156156
{
157157
Method: "GET",
158158
Resource: "/api/2.1/unity-catalog/artifact-allowlists/INIT_SCRIPT?",
159-
Response: apierr.APIErrorBody{
159+
Response: common.APIErrorBody{
160160
ErrorCode: "INVALID_REQUEST",
161161
Message: "Internal error happened",
162162
},
@@ -219,7 +219,7 @@ func TestArtifactAllowlistUpdate_Error(t *testing.T) {
219219
Method: http.MethodPut,
220220
Resource: "/api/2.1/unity-catalog/artifact-allowlists/INIT_SCRIPT",
221221
ExpectedRequest: updateArtifact,
222-
Response: apierr.APIErrorBody{
222+
Response: common.APIErrorBody{
223223
ErrorCode: "SERVER_ERROR",
224224
Message: "Something unexpected happened",
225225
},
@@ -280,7 +280,7 @@ func TestArtifactAllowlistDelete_Error(t *testing.T) {
280280
ArtifactType: catalog.ArtifactTypeInitScript,
281281
ArtifactMatchers: []catalog.ArtifactMatcher{},
282282
},
283-
Response: apierr.APIErrorBody{
283+
Response: common.APIErrorBody{
284284
ErrorCode: "INVALID_STATE",
285285
Message: "Something went wrong",
286286
},

catalog/resource_connection_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"net/http"
55
"testing"
66

7-
"github.com/databricks/databricks-sdk-go/apierr"
87
"github.com/databricks/databricks-sdk-go/service/catalog"
8+
"github.com/databricks/terraform-provider-databricks/common"
99
"github.com/databricks/terraform-provider-databricks/qa"
1010
"github.com/stretchr/testify/assert"
1111
)
@@ -145,7 +145,7 @@ func TestConnectionsCreate_Error(t *testing.T) {
145145
"host": "test.com",
146146
},
147147
},
148-
Response: apierr.APIErrorBody{
148+
Response: common.APIErrorBody{
149149
ErrorCode: "SERVER_ERROR",
150150
Message: "Something unexpected happened",
151151
},
@@ -210,7 +210,7 @@ func TestConnectionRead_Error(t *testing.T) {
210210
{
211211
Method: "GET",
212212
Resource: "/api/2.1/unity-catalog/connections/testConnectionName?",
213-
Response: apierr.APIErrorBody{
213+
Response: common.APIErrorBody{
214214
ErrorCode: "INVALID_REQUEST",
215215
Message: "Internal error happened",
216216
},
@@ -395,7 +395,7 @@ func TestConnectionUpdate_Error(t *testing.T) {
395395
"host": "test.com",
396396
},
397397
},
398-
Response: apierr.APIErrorBody{
398+
Response: common.APIErrorBody{
399399
ErrorCode: "SERVER_ERROR",
400400
Message: "Something unexpected happened",
401401
},
@@ -443,7 +443,7 @@ func TestConnectionDelete_Error(t *testing.T) {
443443
{
444444
Method: http.MethodDelete,
445445
Resource: "/api/2.1/unity-catalog/connections/testConnectionName?",
446-
Response: apierr.APIErrorBody{
446+
Response: common.APIErrorBody{
447447
ErrorCode: "INVALID_STATE",
448448
Message: "Something went wrong",
449449
},

catalog/resource_external_location_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import (
44
"fmt"
55
"testing"
66

7-
"github.com/databricks/databricks-sdk-go/apierr"
87
"github.com/databricks/databricks-sdk-go/experimental/mocks"
98
"github.com/databricks/databricks-sdk-go/service/catalog"
9+
"github.com/databricks/terraform-provider-databricks/common"
1010
"github.com/databricks/terraform-provider-databricks/qa"
1111
"github.com/stretchr/testify/mock"
1212
)
@@ -450,7 +450,7 @@ func TestUpdateExternalLocationRollback(t *testing.T) {
450450
Url: "s3://foo/bar",
451451
CredentialName: "xyz",
452452
},
453-
Response: apierr.APIErrorBody{
453+
Response: common.APIErrorBody{
454454
ErrorCode: "SERVER_ERROR",
455455
Message: "Something unexpected happened",
456456
},
@@ -514,7 +514,7 @@ func TestUpdateExternalLocationRollbackError(t *testing.T) {
514514
Url: "s3://foo/bar",
515515
CredentialName: "xyz",
516516
},
517-
Response: apierr.APIErrorBody{
517+
Response: common.APIErrorBody{
518518
ErrorCode: "SERVER_ERROR",
519519
Message: "Something unexpected happened",
520520
},
@@ -526,7 +526,7 @@ func TestUpdateExternalLocationRollbackError(t *testing.T) {
526526
ExpectedRequest: catalog.UpdateExternalLocation{
527527
Owner: "administrators",
528528
},
529-
Response: apierr.APIErrorBody{
529+
Response: common.APIErrorBody{
530530
ErrorCode: "INVALID_REQUEST",
531531
Message: "Internal error happened",
532532
},

catalog/resource_storage_credential_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ package catalog
33
import (
44
"testing"
55

6-
"github.com/databricks/databricks-sdk-go/apierr"
76
"github.com/databricks/databricks-sdk-go/experimental/mocks"
87
"github.com/databricks/databricks-sdk-go/service/catalog"
8+
"github.com/databricks/terraform-provider-databricks/common"
99
"github.com/databricks/terraform-provider-databricks/qa"
1010
"github.com/stretchr/testify/mock"
1111
)
@@ -506,7 +506,7 @@ func TestUpdateStorageCredentialsRollback(t *testing.T) {
506506
RoleArn: "CHANGED",
507507
},
508508
},
509-
Response: apierr.APIErrorBody{
509+
Response: common.APIErrorBody{
510510
ErrorCode: "SERVER_ERROR",
511511
Message: "Something unexpected happened",
512512
},

0 commit comments

Comments
 (0)