MCPcopy Create free account
hub / github.com/aws-samples/aws-cdk-examples / TestNotebookStack

Function TestNotebookStack

go/sagemaker/notebook/notebook_test.go:11–60  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestNotebookStack(t *testing.T) {
12 // GIVEN
13 app := awscdk.NewApp(nil)
14
15 notebookName := jsii.String("MyNotebook")
16 instanceType := jsii.String("ml.t3.medium")
17 volumeSizeInGb := jsii.Number(5)
18
19 props := &NotebookStackProps{
20 StackProps: awscdk.StackProps{
21 Env: env(),
22 },
23 NotebookName: notebookName,
24 InstanceType: instanceType,
25 VolumeSizeInGb: volumeSizeInGb,
26 }
27
28 // WHEN
29 stack := NewNotebookStack(app, "MyStack", props)
30
31 // THEN
32 template := assertions.Template_FromStack(stack, nil)
33
34 // Test that the stack includes an AWS IAM Role resource
35 template.HasResourceProperties(jsii.String("AWS::IAM::Role"),
36 map[string]interface{}{
37 "AssumeRolePolicyDocument": map[string]interface{}{
38 "Version": "2012-10-17",
39 "Statement": []map[string]interface{}{
40 {
41 "Effect": "Allow",
42 "Principal": map[string]interface{}{
43 "Service": "sagemaker.amazonaws.com",
44 },
45 "Action": "sts:AssumeRole",
46 },
47 },
48 },
49 })
50
51 // Test that the notebook instance has the correct properties
52 template.HasResourceProperties(jsii.String("AWS::SageMaker::NotebookInstance"),
53 map[string]interface{}{
54 "InstanceType": instanceType,
55 "NotebookInstanceName": notebookName,
56 "DirectInternetAccess": "Enabled",
57 "RootAccess": "Disabled",
58 "VolumeSizeInGB": volumeSizeInGb,
59 })
60}

Callers

nothing calls this directly

Calls 2

NewNotebookStackFunction · 0.85
envFunction · 0.70

Tested by

no test coverage detected