mirror of https://github.com/databricks/cli.git
separate test function
This commit is contained in:
parent
3ac1bb1853
commit
8128cc390c
|
@ -16,8 +16,12 @@ import (
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestValidateSingleNodeClusterFail(t *testing.T) {
|
func failCases() []struct {
|
||||||
failCases := []struct {
|
name string
|
||||||
|
sparkConf map[string]string
|
||||||
|
customTags map[string]string
|
||||||
|
} {
|
||||||
|
return []struct {
|
||||||
name string
|
name string
|
||||||
sparkConf map[string]string
|
sparkConf map[string]string
|
||||||
customTags map[string]string
|
customTags map[string]string
|
||||||
|
@ -83,11 +87,12 @@ func TestValidateSingleNodeClusterFail(t *testing.T) {
|
||||||
customTags: map[string]string{"ResourceClass": "SingleNode"},
|
customTags: map[string]string{"ResourceClass": "SingleNode"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestValidateSingleNodeClusterFailForInteractiveClusters(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
// Interactive clusters.
|
for _, tc := range failCases() {
|
||||||
for _, tc := range failCases {
|
|
||||||
t.Run("interactive_"+tc.name, func(t *testing.T) {
|
t.Run("interactive_"+tc.name, func(t *testing.T) {
|
||||||
b := &bundle.Bundle{
|
b := &bundle.Bundle{
|
||||||
Config: config.Root{
|
Config: config.Root{
|
||||||
|
@ -123,9 +128,12 @@ func TestValidateSingleNodeClusterFail(t *testing.T) {
|
||||||
}, diags)
|
}, diags)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Job clusters.
|
func TestValidateSingleNodeClusterFailForJobClusters(t *testing.T) {
|
||||||
for _, tc := range failCases {
|
ctx := context.Background()
|
||||||
|
|
||||||
|
for _, tc := range failCases() {
|
||||||
t.Run("job_"+tc.name, func(t *testing.T) {
|
t.Run("job_"+tc.name, func(t *testing.T) {
|
||||||
b := &bundle.Bundle{
|
b := &bundle.Bundle{
|
||||||
Config: config.Root{
|
Config: config.Root{
|
||||||
|
@ -170,9 +178,12 @@ func TestValidateSingleNodeClusterFail(t *testing.T) {
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Job task clusters.
|
func TestValidateSingleNodeClusterFailForJobTaskClusters(t *testing.T) {
|
||||||
for _, tc := range failCases {
|
ctx := context.Background()
|
||||||
|
|
||||||
|
for _, tc := range failCases() {
|
||||||
t.Run("task_"+tc.name, func(t *testing.T) {
|
t.Run("task_"+tc.name, func(t *testing.T) {
|
||||||
b := &bundle.Bundle{
|
b := &bundle.Bundle{
|
||||||
Config: config.Root{
|
Config: config.Root{
|
||||||
|
@ -216,9 +227,12 @@ func TestValidateSingleNodeClusterFail(t *testing.T) {
|
||||||
}, diags)
|
}, diags)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Pipeline clusters.
|
func TestValidateSingleNodeClusterFailForPipelineClusters(t *testing.T) {
|
||||||
for _, tc := range failCases {
|
ctx := context.Background()
|
||||||
|
|
||||||
|
for _, tc := range failCases() {
|
||||||
t.Run("pipeline_"+tc.name, func(t *testing.T) {
|
t.Run("pipeline_"+tc.name, func(t *testing.T) {
|
||||||
b := &bundle.Bundle{
|
b := &bundle.Bundle{
|
||||||
Config: config.Root{
|
Config: config.Root{
|
||||||
|
@ -259,14 +273,19 @@ func TestValidateSingleNodeClusterFail(t *testing.T) {
|
||||||
}, diags)
|
}, diags)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidateSingleNodeClusterPass(t *testing.T) {
|
func passCases() []struct {
|
||||||
|
name string
|
||||||
|
numWorkers *int
|
||||||
|
sparkConf map[string]string
|
||||||
|
customTags map[string]string
|
||||||
|
policyId string
|
||||||
|
} {
|
||||||
zero := 0
|
zero := 0
|
||||||
one := 1
|
one := 1
|
||||||
|
|
||||||
passCases := []struct {
|
return []struct {
|
||||||
name string
|
name string
|
||||||
numWorkers *int
|
numWorkers *int
|
||||||
sparkConf map[string]string
|
sparkConf map[string]string
|
||||||
|
@ -297,11 +316,12 @@ func TestValidateSingleNodeClusterPass(t *testing.T) {
|
||||||
numWorkers: &zero,
|
numWorkers: &zero,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestValidateSingleNodeClusterPassInteractiveClusters(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
// Interactive clusters.
|
for _, tc := range passCases() {
|
||||||
for _, tc := range passCases {
|
|
||||||
t.Run("interactive_"+tc.name, func(t *testing.T) {
|
t.Run("interactive_"+tc.name, func(t *testing.T) {
|
||||||
b := &bundle.Bundle{
|
b := &bundle.Bundle{
|
||||||
Config: config.Root{
|
Config: config.Root{
|
||||||
|
@ -329,9 +349,12 @@ func TestValidateSingleNodeClusterPass(t *testing.T) {
|
||||||
assert.Empty(t, diags)
|
assert.Empty(t, diags)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Job clusters.
|
func TestValidateSingleNodeClusterPassJobClusters(t *testing.T) {
|
||||||
for _, tc := range passCases {
|
ctx := context.Background()
|
||||||
|
|
||||||
|
for _, tc := range passCases() {
|
||||||
t.Run("job_"+tc.name, func(t *testing.T) {
|
t.Run("job_"+tc.name, func(t *testing.T) {
|
||||||
b := &bundle.Bundle{
|
b := &bundle.Bundle{
|
||||||
Config: config.Root{
|
Config: config.Root{
|
||||||
|
@ -366,9 +389,12 @@ func TestValidateSingleNodeClusterPass(t *testing.T) {
|
||||||
assert.Empty(t, diags)
|
assert.Empty(t, diags)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Job task clusters.
|
func TestValidateSingleNodeClusterPassJobTaskClusters(t *testing.T) {
|
||||||
for _, tc := range passCases {
|
ctx := context.Background()
|
||||||
|
|
||||||
|
for _, tc := range passCases() {
|
||||||
t.Run("task_"+tc.name, func(t *testing.T) {
|
t.Run("task_"+tc.name, func(t *testing.T) {
|
||||||
b := &bundle.Bundle{
|
b := &bundle.Bundle{
|
||||||
Config: config.Root{
|
Config: config.Root{
|
||||||
|
@ -403,9 +429,12 @@ func TestValidateSingleNodeClusterPass(t *testing.T) {
|
||||||
assert.Empty(t, diags)
|
assert.Empty(t, diags)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Pipeline clusters.
|
func TestValidateSingleNodeClusterPassPipelineClusters(t *testing.T) {
|
||||||
for _, tc := range passCases {
|
ctx := context.Background()
|
||||||
|
|
||||||
|
for _, tc := range passCases() {
|
||||||
t.Run("pipeline_"+tc.name, func(t *testing.T) {
|
t.Run("pipeline_"+tc.name, func(t *testing.T) {
|
||||||
b := &bundle.Bundle{
|
b := &bundle.Bundle{
|
||||||
Config: config.Root{
|
Config: config.Root{
|
||||||
|
|
Loading…
Reference in New Issue