-
Notifications
You must be signed in to change notification settings - Fork 215
Expand file tree
/
Copy pathcompute_test.go
More file actions
104 lines (97 loc) · 2.43 KB
/
Copy pathcompute_test.go
File metadata and controls
104 lines (97 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package metadata
import (
"context"
"testing"
"github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/config"
"github.com/databricks/cli/bundle/config/paths"
"github.com/databricks/cli/bundle/config/resources"
"github.com/databricks/cli/bundle/metadata"
"github.com/databricks/databricks-sdk-go/service/jobs"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestComputeMetadataMutator(t *testing.T) {
b := &bundle.Bundle{
Config: config.Root{
Workspace: config.Workspace{
RootPath: "/Users/shreyas.goenka@databricks.com",
ArtifactPath: "/Users/shreyas.goenka@databricks.com/artifacts",
FilePath: "/Users/shreyas.goenka@databricks.com/files",
},
Bundle: config.Bundle{
Name: "my-bundle",
Target: "development",
Git: config.Git{
Branch: "my-branch",
OriginURL: "www.host.com",
Commit: "abcd",
BundleRootPath: "a/b/c/d",
Inferred: true,
},
},
Resources: config.Resources{
Jobs: map[string]*resources.Job{
"my-job-1": {
Paths: paths.Paths{
ConfigFilePath: "a/b/c",
},
ID: "1111",
JobSettings: &jobs.JobSettings{
Name: "My Job One",
},
},
"my-job-2": {
Paths: paths.Paths{
ConfigFilePath: "d/e/f",
},
ID: "2222",
JobSettings: &jobs.JobSettings{
Name: "My Job Two",
},
},
},
Pipelines: map[string]*resources.Pipeline{
"my-pipeline": {
Paths: paths.Paths{
ConfigFilePath: "abc",
},
},
},
},
},
}
expectedMetadata := metadata.Metadata{
Version: metadata.Version,
Config: metadata.Config{
Workspace: metadata.Workspace{
FilePath: "/Users/shreyas.goenka@databricks.com/files",
},
Bundle: metadata.Bundle{
Git: config.Git{
Branch: "my-branch",
OriginURL: "www.host.com",
Commit: "abcd",
BundleRootPath: "a/b/c/d",
// Test that this field doesn't carry over into the metadata.
Inferred: false,
},
},
Resources: metadata.Resources{
Jobs: map[string]*metadata.Job{
"my-job-1": {
RelativePath: "a/b/c",
ID: "1111",
},
"my-job-2": {
RelativePath: "d/e/f",
ID: "2222",
},
},
},
},
}
err := bundle.Apply(context.Background(), b, Compute())
require.NoError(t, err)
assert.Equal(t, expectedMetadata, b.Metadata)
}