2022-11-18 10:12:24 +00:00
|
|
|
package config_tests
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2023-07-12 06:51:54 +00:00
|
|
|
"github.com/databricks/cli/bundle/config"
|
2022-11-18 10:12:24 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestJobAndPipelineDevelopment(t *testing.T) {
|
2023-08-17 15:22:32 +00:00
|
|
|
b := loadTarget(t, "./job_and_pipeline", "development")
|
2022-12-01 21:39:15 +00:00
|
|
|
assert.Len(t, b.Config.Resources.Jobs, 0)
|
2022-11-28 09:59:43 +00:00
|
|
|
assert.Len(t, b.Config.Resources.Pipelines, 1)
|
2022-11-18 10:12:24 +00:00
|
|
|
|
2022-11-28 09:59:43 +00:00
|
|
|
p := b.Config.Resources.Pipelines["nyc_taxi_pipeline"]
|
2023-07-12 06:51:54 +00:00
|
|
|
assert.Equal(t, b.Config.Bundle.Mode, config.Development)
|
2022-11-18 10:12:24 +00:00
|
|
|
assert.True(t, p.Development)
|
|
|
|
require.Len(t, p.Libraries, 1)
|
|
|
|
assert.Equal(t, "./dlt/nyc_taxi_loader", p.Libraries[0].Notebook.Path)
|
|
|
|
assert.Equal(t, "nyc_taxi_development", p.Target)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestJobAndPipelineStaging(t *testing.T) {
|
2023-08-17 15:22:32 +00:00
|
|
|
b := loadTarget(t, "./job_and_pipeline", "staging")
|
2022-12-01 21:39:15 +00:00
|
|
|
assert.Len(t, b.Config.Resources.Jobs, 0)
|
2022-11-28 09:59:43 +00:00
|
|
|
assert.Len(t, b.Config.Resources.Pipelines, 1)
|
2022-11-18 10:12:24 +00:00
|
|
|
|
2022-11-28 09:59:43 +00:00
|
|
|
p := b.Config.Resources.Pipelines["nyc_taxi_pipeline"]
|
2022-11-18 10:12:24 +00:00
|
|
|
assert.False(t, p.Development)
|
|
|
|
require.Len(t, p.Libraries, 1)
|
|
|
|
assert.Equal(t, "./dlt/nyc_taxi_loader", p.Libraries[0].Notebook.Path)
|
|
|
|
assert.Equal(t, "nyc_taxi_staging", p.Target)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestJobAndPipelineProduction(t *testing.T) {
|
2023-08-17 15:22:32 +00:00
|
|
|
b := loadTarget(t, "./job_and_pipeline", "production")
|
2022-12-01 21:39:15 +00:00
|
|
|
assert.Len(t, b.Config.Resources.Jobs, 1)
|
2022-11-28 09:59:43 +00:00
|
|
|
assert.Len(t, b.Config.Resources.Pipelines, 1)
|
2022-11-18 10:12:24 +00:00
|
|
|
|
2022-11-28 09:59:43 +00:00
|
|
|
p := b.Config.Resources.Pipelines["nyc_taxi_pipeline"]
|
2022-11-18 10:12:24 +00:00
|
|
|
assert.False(t, p.Development)
|
|
|
|
require.Len(t, p.Libraries, 1)
|
|
|
|
assert.Equal(t, "./dlt/nyc_taxi_loader", p.Libraries[0].Notebook.Path)
|
|
|
|
assert.Equal(t, "nyc_taxi_production", p.Target)
|
|
|
|
|
2022-12-01 21:39:15 +00:00
|
|
|
j := b.Config.Resources.Jobs["pipeline_schedule"]
|
2022-11-18 10:12:24 +00:00
|
|
|
assert.Equal(t, "Daily refresh of production pipeline", j.Name)
|
|
|
|
require.Len(t, j.Tasks, 1)
|
|
|
|
assert.NotEmpty(t, j.Tasks[0].PipelineTask.PipelineId)
|
|
|
|
}
|