Skip to content

Commit

Permalink
add typesctipt tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Shchederkin committed Dec 16, 2024
1 parent 00beb49 commit 25ab281
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 4 deletions.
3 changes: 3 additions & 0 deletions typescript/src/resources/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import exp from "constants";

Check warning on line 1 in typescript/src/resources/index.ts

View workflow job for this annotation

GitHub Actions / linting

'exp' is defined but never used

export * as account from "./account";
export * as clusterPolicies from "./cluster-policies";
export * as clusters from "./clusters";
Expand Down Expand Up @@ -30,3 +32,4 @@ export * from "./sql-warehouses";
export * from "./unity-catalog";
export * from "./tokens";
export * from "./mlflow";
export * from "./service-principals";
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Template } from "aws-cdk-lib/assertions";
import * as cdk from "aws-cdk-lib";
import { DatabricksDeployLambda, ServicePrincipal } from "../../../../typescript/src";


describe("ServicePrincipal", () => {
test("RegisteredModel Custom Resource synthesizes the way we expect", () => {
const app = new cdk.App();
const databricksStack = new cdk.Stack(app, "DatabricksStack");
const deployLambda = DatabricksDeployLambda.fromServiceToken(databricksStack, "DeployLambda", "some-arn");
const workspaceUrl = cdk.Fn.importValue("databricks-workspace-url");
new ServicePrincipal(databricksStack, "ServicePrincipal", {
service_principal: {
active: true,
application_id: "some_id",
display_name: "some_name",
roles: [{ value: "some_role" }],
},
workspace_url: workspaceUrl.toString(),
serviceToken: deployLambda.serviceToken.toString(),
});

const template = Template.fromStack(databricksStack);

template.hasResourceProperties("AWS::CloudFormation::CustomResource",
{

"ServiceToken": "some-arn",
"action": "service-principal",
"workspace_url": {
"Fn::ImportValue": "databricks-workspace-url"
},
"service_principal": {
"active": true,
"application_id": "some_id",
"display_name": "some_name",
"roles": [{ "value": "some_role" }]
}
});
});
});

15 changes: 11 additions & 4 deletions typescript/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
{
"compilerOptions": {
"target":"ES2018",
"target": "ES2018",
"module": "commonjs",
"esModuleInterop": true,
"lib": ["es2016", "es2017.object", "es2017.string"],
"lib": [
"es2016",
"es2017.object",
"es2017.string"
],
"declaration": true,
"strict": true,
"outDir": "./dist"
},
"include": ["src/**/*"]
}
"include": [
"src/**/*",
"tests/**/*"
]
}

0 comments on commit 25ab281

Please sign in to comment.