Skip to content

Commit

Permalink
Fix tests after the Go SDK upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
alexott committed Dec 9, 2023
1 parent 6459a7b commit be106f2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
2 changes: 2 additions & 0 deletions exporter/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1553,6 +1553,7 @@ func TestImportingRepos(t *testing.T) {
[]qa.HTTPFixture{
meAdminFixture,
userListIdUsernameFixture,
userListIdUsernameFixture2,
userListFixture,
userReadFixture,
{
Expand Down Expand Up @@ -1980,6 +1981,7 @@ func TestImportingDLTPipelinesMatchingOnly(t *testing.T) {
emptyRepos,
emptyIpAccessLIst,
userListIdUsernameFixture,
userListIdUsernameFixture2,
userListFixture,
userReadFixture,
{
Expand Down
2 changes: 1 addition & 1 deletion exporter/importables.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var (
fileNameNormalizationRegex = regexp.MustCompile(`[^-_\w/.@]`)
jobClustersRegex = regexp.MustCompile(`^((job_cluster|task)\.[0-9]+\.new_cluster\.[0-9]+\.)`)
dltClusterRegex = regexp.MustCompile(`^(cluster\.[0-9]+\.)`)
userDirRegex = regexp.MustCompile(`^(/Users/[^/]+)(/.*)?$`)
userDirRegex = regexp.MustCompile(`^(/Users/[^/]+)(/.*)?$`)
secretPathRegex = regexp.MustCompile(`^\{\{secrets\/([^\/]+)\/([^}]+)\}\}$`)
sqlParentRegexp = regexp.MustCompile(`^folders/(\d+)$`)
dltDefaultStorageRegex = regexp.MustCompile(`^dbfs:/pipelines/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`)
Expand Down
38 changes: 35 additions & 3 deletions exporter/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,28 @@ func TestAddAwsMounts(t *testing.T) {
var (
userListIdUsernameFixture = qa.HTTPFixture{
Method: "GET",
Resource: "/api/2.0/preview/scim/v2/Users?attributes=userName%2Cid",
Resource: "/api/2.0/preview/scim/v2/Users?attributes=id%2CuserName&count=100&startIndex=1",
Response: iam.ListUsersResponse{
Resources: []iam.User{
{
Id: "id",
UserName: "user@domain.com",
},
},
TotalResults: 1,
StartIndex: 1,
},
ReuseRequest: true,
}
userListIdUsernameFixture2 = qa.HTTPFixture{
Method: "GET",
Resource: "/api/2.0/preview/scim/v2/Users?attributes=id%2CuserName&count=100&startIndex=2",
Response: iam.ListUsersResponse{
Resources: []iam.User{},
TotalResults: 1,
StartIndex: 2,
},
ReuseRequest: true,
}
userListFixture = qa.HTTPFixture{
Method: "GET",
Expand All @@ -70,14 +83,25 @@ var (
}
spListIdUsernameFixture = qa.HTTPFixture{
Method: "GET",
Resource: "/api/2.0/preview/scim/v2/ServicePrincipals?attributes=id%2CuserName",
Resource: "/api/2.0/preview/scim/v2/ServicePrincipals?attributes=id%2CuserName&count=100&startIndex=1",
Response: iam.ListServicePrincipalResponse{
Resources: []iam.ServicePrincipal{
{
Id: "id",
ApplicationId: "21aab5a7-ee70-4385-34d4-a77278be5cb6",
},
},
TotalResults: 1,
StartIndex: 1,
},
}
spListIdUsernameFixture2 = qa.HTTPFixture{
Method: "GET",
Resource: "/api/2.0/preview/scim/v2/ServicePrincipals?attributes=id%2CuserName&count=100&startIndex=2",
Response: iam.ListServicePrincipalResponse{
Resources: []iam.ServicePrincipal{},
TotalResults: 1,
StartIndex: 2,
},
}
spListFixture = qa.HTTPFixture{
Expand Down Expand Up @@ -105,6 +129,7 @@ var (
func TestEmitUser(t *testing.T) {
qa.HTTPFixturesApply(t, []qa.HTTPFixture{
userListIdUsernameFixture,
userListIdUsernameFixture2,
userListFixture,
userReadFixture,
}, func(ctx context.Context, client *common.DatabricksClient) {
Expand All @@ -119,6 +144,7 @@ func TestEmitUser(t *testing.T) {
func TestEmitServicePrincipal(t *testing.T) {
qa.HTTPFixturesApply(t, []qa.HTTPFixture{
spListIdUsernameFixture,
spListIdUsernameFixture2,
spListFixture,
spReadFixture,
}, func(ctx context.Context, client *common.DatabricksClient) {
Expand All @@ -133,7 +159,7 @@ func TestEmitUserError(t *testing.T) {
qa.HTTPFixturesApply(t, []qa.HTTPFixture{
{
Method: "GET",
Resource: "/api/2.0/preview/scim/v2/Users?attributes=userName%2Cid",
Resource: "/api/2.0/preview/scim/v2/Users?attributes=id%2CuserName&count=100&startIndex=1",
Response: iam.ListUsersResponse{
Resources: []iam.User{},
},
Expand All @@ -148,6 +174,7 @@ func TestEmitUserError(t *testing.T) {
func TestEmitUserOrServicePrincipalForPath(t *testing.T) {
qa.HTTPFixturesApply(t, []qa.HTTPFixture{
userListIdUsernameFixture,
userListIdUsernameFixture2,
userListFixture,
userReadFixture,
}, func(ctx context.Context, client *common.DatabricksClient) {
Expand All @@ -172,6 +199,7 @@ func TestEmitUserOrServicePrincipalForPath_NoEmit(t *testing.T) {
func TestEmitNotebookOrRepo(t *testing.T) {
qa.HTTPFixturesApply(t, []qa.HTTPFixture{
userListIdUsernameFixture,
userListIdUsernameFixture2,
userListFixture,
userReadFixture,
}, func(ctx context.Context, client *common.DatabricksClient) {
Expand All @@ -197,6 +225,7 @@ func TestEmitNotebookOrRepo(t *testing.T) {
func TestIsUserOrServicePrincipalDirectory(t *testing.T) {
qa.HTTPFixturesApply(t, []qa.HTTPFixture{
userListIdUsernameFixture,
userListIdUsernameFixture2,
userListFixture,
userReadFixture,
}, func(ctx context.Context, client *common.DatabricksClient) {
Expand All @@ -219,6 +248,7 @@ func TestIsUserOrServicePrincipalDirectory(t *testing.T) {

qa.HTTPFixturesApply(t, []qa.HTTPFixture{
userListIdUsernameFixture,
userListIdUsernameFixture2,
userListFixture,
userReadFixture,
}, func(ctx context.Context, client *common.DatabricksClient) {
Expand All @@ -229,6 +259,7 @@ func TestIsUserOrServicePrincipalDirectory(t *testing.T) {

qa.HTTPFixturesApply(t, []qa.HTTPFixture{
userListIdUsernameFixture,
userListIdUsernameFixture2,
userListFixture,
userReadFixture,
}, func(ctx context.Context, client *common.DatabricksClient) {
Expand All @@ -239,6 +270,7 @@ func TestIsUserOrServicePrincipalDirectory(t *testing.T) {

qa.HTTPFixturesApply(t, []qa.HTTPFixture{
spListIdUsernameFixture,
spListIdUsernameFixture2,
spListFixture,
spReadFixture,
}, func(ctx context.Context, client *common.DatabricksClient) {
Expand Down

0 comments on commit be106f2

Please sign in to comment.