Skip to content

Commit

Permalink
separate test function
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyas-goenka committed Nov 22, 2024
1 parent 3ac1bb1 commit 8128cc3
Showing 1 changed file with 50 additions and 21 deletions.
71 changes: 50 additions & 21 deletions bundle/config/validate/single_node_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ import (
"github.com/stretchr/testify/assert"
)

func TestValidateSingleNodeClusterFail(t *testing.T) {
failCases := []struct {
func failCases() []struct {
name string
sparkConf map[string]string
customTags map[string]string
} {
return []struct {
name string
sparkConf map[string]string
customTags map[string]string
Expand Down Expand Up @@ -83,11 +87,12 @@ func TestValidateSingleNodeClusterFail(t *testing.T) {
customTags: map[string]string{"ResourceClass": "SingleNode"},
},
}
}

func TestValidateSingleNodeClusterFailForInteractiveClusters(t *testing.T) {
ctx := context.Background()

// Interactive clusters.
for _, tc := range failCases {
for _, tc := range failCases() {
t.Run("interactive_"+tc.name, func(t *testing.T) {
b := &bundle.Bundle{
Config: config.Root{
Expand Down Expand Up @@ -123,9 +128,12 @@ func TestValidateSingleNodeClusterFail(t *testing.T) {
}, diags)
})
}
}

func TestValidateSingleNodeClusterFailForJobClusters(t *testing.T) {
ctx := context.Background()

// Job clusters.
for _, tc := range failCases {
for _, tc := range failCases() {
t.Run("job_"+tc.name, func(t *testing.T) {
b := &bundle.Bundle{
Config: config.Root{
Expand Down Expand Up @@ -170,9 +178,12 @@ func TestValidateSingleNodeClusterFail(t *testing.T) {

})
}
}

// Job task clusters.
for _, tc := range failCases {
func TestValidateSingleNodeClusterFailForJobTaskClusters(t *testing.T) {
ctx := context.Background()

for _, tc := range failCases() {
t.Run("task_"+tc.name, func(t *testing.T) {
b := &bundle.Bundle{
Config: config.Root{
Expand Down Expand Up @@ -216,9 +227,12 @@ func TestValidateSingleNodeClusterFail(t *testing.T) {
}, diags)
})
}
}

// Pipeline clusters.
for _, tc := range failCases {
func TestValidateSingleNodeClusterFailForPipelineClusters(t *testing.T) {
ctx := context.Background()

for _, tc := range failCases() {
t.Run("pipeline_"+tc.name, func(t *testing.T) {
b := &bundle.Bundle{
Config: config.Root{
Expand Down Expand Up @@ -259,14 +273,19 @@ func TestValidateSingleNodeClusterFail(t *testing.T) {
}, 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
one := 1

passCases := []struct {
return []struct {
name string
numWorkers *int
sparkConf map[string]string
Expand Down Expand Up @@ -297,11 +316,12 @@ func TestValidateSingleNodeClusterPass(t *testing.T) {
numWorkers: &zero,
},
}
}

func TestValidateSingleNodeClusterPassInteractiveClusters(t *testing.T) {
ctx := context.Background()

// Interactive clusters.
for _, tc := range passCases {
for _, tc := range passCases() {
t.Run("interactive_"+tc.name, func(t *testing.T) {
b := &bundle.Bundle{
Config: config.Root{
Expand Down Expand Up @@ -329,9 +349,12 @@ func TestValidateSingleNodeClusterPass(t *testing.T) {
assert.Empty(t, diags)
})
}
}

// Job clusters.
for _, tc := range passCases {
func TestValidateSingleNodeClusterPassJobClusters(t *testing.T) {
ctx := context.Background()

for _, tc := range passCases() {
t.Run("job_"+tc.name, func(t *testing.T) {
b := &bundle.Bundle{
Config: config.Root{
Expand Down Expand Up @@ -366,9 +389,12 @@ func TestValidateSingleNodeClusterPass(t *testing.T) {
assert.Empty(t, diags)
})
}
}

// Job task clusters.
for _, tc := range passCases {
func TestValidateSingleNodeClusterPassJobTaskClusters(t *testing.T) {
ctx := context.Background()

for _, tc := range passCases() {
t.Run("task_"+tc.name, func(t *testing.T) {
b := &bundle.Bundle{
Config: config.Root{
Expand Down Expand Up @@ -403,9 +429,12 @@ func TestValidateSingleNodeClusterPass(t *testing.T) {
assert.Empty(t, diags)
})
}
}

func TestValidateSingleNodeClusterPassPipelineClusters(t *testing.T) {
ctx := context.Background()

// Pipeline clusters.
for _, tc := range passCases {
for _, tc := range passCases() {
t.Run("pipeline_"+tc.name, func(t *testing.T) {
b := &bundle.Bundle{
Config: config.Root{
Expand Down

0 comments on commit 8128cc3

Please sign in to comment.