From f202596a6fa85451dee82d3ebe98840f8cd05c23 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Thu, 21 Mar 2024 11:37:05 +0100 Subject: [PATCH] Move bundle tests into bundle/tests (#1299) ## Changes These tests were located in `bundle/tests/bundle` which meant they were unable to reuse the helper functions defined in the `bundle/tests` package. There is no need for these tests to live outside the package. ## Tests Existing tests pass. --- bundle/tests/bundle/loader.go | 26 ------------------ .../pipeline_glob_paths/databricks.yml | 0 .../dlt/nyc_taxi_loader.py | 0 .../{bundle => }/pipeline_glob_paths_test.go | 2 +- .../python_wheel/.gitignore | 0 .../python_wheel/bundle.yml | 0 .../python_wheel/my_test_code/setup.py | 0 .../python_wheel/my_test_code/src/__init__.py | 0 .../python_wheel/my_test_code/src/__main__.py | 0 .../python_wheel_dbfs_lib/bundle.yml | 0 .../python_wheel_no_artifact/.gitignore | 0 .../python_wheel_no_artifact/bundle.yml | 0 .../my_test_code/__init__.py | 0 .../my_test_code/__main__.py | 0 .../python_wheel_no_artifact/setup.py | 0 .../.gitignore | 0 .../bundle.yml | 0 .../my_test_code-0.0.1-py3-none-any.whl | Bin .../wheel_test.go => python_wheel_test.go} | 22 +++++++-------- 19 files changed, 12 insertions(+), 38 deletions(-) delete mode 100644 bundle/tests/bundle/loader.go rename bundle/tests/{bundle => }/pipeline_glob_paths/databricks.yml (100%) rename bundle/tests/{bundle => }/pipeline_glob_paths/dlt/nyc_taxi_loader.py (100%) rename bundle/tests/{bundle => }/pipeline_glob_paths_test.go (98%) rename bundle/tests/{bundle => python_wheel}/python_wheel/.gitignore (100%) rename bundle/tests/{bundle => python_wheel}/python_wheel/bundle.yml (100%) rename bundle/tests/{bundle => python_wheel}/python_wheel/my_test_code/setup.py (100%) rename bundle/tests/{bundle => python_wheel}/python_wheel/my_test_code/src/__init__.py (100%) rename bundle/tests/{bundle => python_wheel}/python_wheel/my_test_code/src/__main__.py (100%) rename bundle/tests/{bundle => python_wheel}/python_wheel_dbfs_lib/bundle.yml (100%) rename bundle/tests/{bundle => python_wheel}/python_wheel_no_artifact/.gitignore (100%) rename bundle/tests/{bundle => python_wheel}/python_wheel_no_artifact/bundle.yml (100%) rename bundle/tests/{bundle => python_wheel}/python_wheel_no_artifact/my_test_code/__init__.py (100%) rename bundle/tests/{bundle => python_wheel}/python_wheel_no_artifact/my_test_code/__main__.py (100%) rename bundle/tests/{bundle => python_wheel}/python_wheel_no_artifact/setup.py (100%) rename bundle/tests/{bundle => python_wheel}/python_wheel_no_artifact_no_setup/.gitignore (100%) rename bundle/tests/{bundle => python_wheel}/python_wheel_no_artifact_no_setup/bundle.yml (100%) rename bundle/tests/{bundle => python_wheel}/python_wheel_no_artifact_no_setup/package/my_test_code-0.0.1-py3-none-any.whl (100%) rename bundle/tests/{bundle/wheel_test.go => python_wheel_test.go} (70%) diff --git a/bundle/tests/bundle/loader.go b/bundle/tests/bundle/loader.go deleted file mode 100644 index 52744ca7..00000000 --- a/bundle/tests/bundle/loader.go +++ /dev/null @@ -1,26 +0,0 @@ -package bundle - -import ( - "context" - "testing" - - "github.com/databricks/cli/bundle" - "github.com/databricks/cli/bundle/config/mutator" - "github.com/stretchr/testify/require" -) - -func loadTarget(t *testing.T, path, env string) *bundle.Bundle { - ctx := context.Background() - b, err := bundle.Load(ctx, path) - require.NoError(t, err) - err = bundle.Apply(ctx, b, bundle.Seq(mutator.DefaultMutatorsForTarget(env)...)) - require.NoError(t, err) - err = bundle.Apply(ctx, b, bundle.Seq( - mutator.RewriteSyncPaths(), - mutator.MergeJobClusters(), - mutator.MergeJobTasks(), - mutator.MergePipelineClusters(), - )) - require.NoError(t, err) - return b -} diff --git a/bundle/tests/bundle/pipeline_glob_paths/databricks.yml b/bundle/tests/pipeline_glob_paths/databricks.yml similarity index 100% rename from bundle/tests/bundle/pipeline_glob_paths/databricks.yml rename to bundle/tests/pipeline_glob_paths/databricks.yml diff --git a/bundle/tests/bundle/pipeline_glob_paths/dlt/nyc_taxi_loader.py b/bundle/tests/pipeline_glob_paths/dlt/nyc_taxi_loader.py similarity index 100% rename from bundle/tests/bundle/pipeline_glob_paths/dlt/nyc_taxi_loader.py rename to bundle/tests/pipeline_glob_paths/dlt/nyc_taxi_loader.py diff --git a/bundle/tests/bundle/pipeline_glob_paths_test.go b/bundle/tests/pipeline_glob_paths_test.go similarity index 98% rename from bundle/tests/bundle/pipeline_glob_paths_test.go rename to bundle/tests/pipeline_glob_paths_test.go index ed78c966..85a13792 100644 --- a/bundle/tests/bundle/pipeline_glob_paths_test.go +++ b/bundle/tests/pipeline_glob_paths_test.go @@ -1,4 +1,4 @@ -package bundle +package config_tests import ( "context" diff --git a/bundle/tests/bundle/python_wheel/.gitignore b/bundle/tests/python_wheel/python_wheel/.gitignore similarity index 100% rename from bundle/tests/bundle/python_wheel/.gitignore rename to bundle/tests/python_wheel/python_wheel/.gitignore diff --git a/bundle/tests/bundle/python_wheel/bundle.yml b/bundle/tests/python_wheel/python_wheel/bundle.yml similarity index 100% rename from bundle/tests/bundle/python_wheel/bundle.yml rename to bundle/tests/python_wheel/python_wheel/bundle.yml diff --git a/bundle/tests/bundle/python_wheel/my_test_code/setup.py b/bundle/tests/python_wheel/python_wheel/my_test_code/setup.py similarity index 100% rename from bundle/tests/bundle/python_wheel/my_test_code/setup.py rename to bundle/tests/python_wheel/python_wheel/my_test_code/setup.py diff --git a/bundle/tests/bundle/python_wheel/my_test_code/src/__init__.py b/bundle/tests/python_wheel/python_wheel/my_test_code/src/__init__.py similarity index 100% rename from bundle/tests/bundle/python_wheel/my_test_code/src/__init__.py rename to bundle/tests/python_wheel/python_wheel/my_test_code/src/__init__.py diff --git a/bundle/tests/bundle/python_wheel/my_test_code/src/__main__.py b/bundle/tests/python_wheel/python_wheel/my_test_code/src/__main__.py similarity index 100% rename from bundle/tests/bundle/python_wheel/my_test_code/src/__main__.py rename to bundle/tests/python_wheel/python_wheel/my_test_code/src/__main__.py diff --git a/bundle/tests/bundle/python_wheel_dbfs_lib/bundle.yml b/bundle/tests/python_wheel/python_wheel_dbfs_lib/bundle.yml similarity index 100% rename from bundle/tests/bundle/python_wheel_dbfs_lib/bundle.yml rename to bundle/tests/python_wheel/python_wheel_dbfs_lib/bundle.yml diff --git a/bundle/tests/bundle/python_wheel_no_artifact/.gitignore b/bundle/tests/python_wheel/python_wheel_no_artifact/.gitignore similarity index 100% rename from bundle/tests/bundle/python_wheel_no_artifact/.gitignore rename to bundle/tests/python_wheel/python_wheel_no_artifact/.gitignore diff --git a/bundle/tests/bundle/python_wheel_no_artifact/bundle.yml b/bundle/tests/python_wheel/python_wheel_no_artifact/bundle.yml similarity index 100% rename from bundle/tests/bundle/python_wheel_no_artifact/bundle.yml rename to bundle/tests/python_wheel/python_wheel_no_artifact/bundle.yml diff --git a/bundle/tests/bundle/python_wheel_no_artifact/my_test_code/__init__.py b/bundle/tests/python_wheel/python_wheel_no_artifact/my_test_code/__init__.py similarity index 100% rename from bundle/tests/bundle/python_wheel_no_artifact/my_test_code/__init__.py rename to bundle/tests/python_wheel/python_wheel_no_artifact/my_test_code/__init__.py diff --git a/bundle/tests/bundle/python_wheel_no_artifact/my_test_code/__main__.py b/bundle/tests/python_wheel/python_wheel_no_artifact/my_test_code/__main__.py similarity index 100% rename from bundle/tests/bundle/python_wheel_no_artifact/my_test_code/__main__.py rename to bundle/tests/python_wheel/python_wheel_no_artifact/my_test_code/__main__.py diff --git a/bundle/tests/bundle/python_wheel_no_artifact/setup.py b/bundle/tests/python_wheel/python_wheel_no_artifact/setup.py similarity index 100% rename from bundle/tests/bundle/python_wheel_no_artifact/setup.py rename to bundle/tests/python_wheel/python_wheel_no_artifact/setup.py diff --git a/bundle/tests/bundle/python_wheel_no_artifact_no_setup/.gitignore b/bundle/tests/python_wheel/python_wheel_no_artifact_no_setup/.gitignore similarity index 100% rename from bundle/tests/bundle/python_wheel_no_artifact_no_setup/.gitignore rename to bundle/tests/python_wheel/python_wheel_no_artifact_no_setup/.gitignore diff --git a/bundle/tests/bundle/python_wheel_no_artifact_no_setup/bundle.yml b/bundle/tests/python_wheel/python_wheel_no_artifact_no_setup/bundle.yml similarity index 100% rename from bundle/tests/bundle/python_wheel_no_artifact_no_setup/bundle.yml rename to bundle/tests/python_wheel/python_wheel_no_artifact_no_setup/bundle.yml diff --git a/bundle/tests/bundle/python_wheel_no_artifact_no_setup/package/my_test_code-0.0.1-py3-none-any.whl b/bundle/tests/python_wheel/python_wheel_no_artifact_no_setup/package/my_test_code-0.0.1-py3-none-any.whl similarity index 100% rename from bundle/tests/bundle/python_wheel_no_artifact_no_setup/package/my_test_code-0.0.1-py3-none-any.whl rename to bundle/tests/python_wheel/python_wheel_no_artifact_no_setup/package/my_test_code-0.0.1-py3-none-any.whl diff --git a/bundle/tests/bundle/wheel_test.go b/bundle/tests/python_wheel_test.go similarity index 70% rename from bundle/tests/bundle/wheel_test.go rename to bundle/tests/python_wheel_test.go index 5171241f..8351e96a 100644 --- a/bundle/tests/bundle/wheel_test.go +++ b/bundle/tests/python_wheel_test.go @@ -1,4 +1,4 @@ -package bundle +package config_tests import ( "context" @@ -11,16 +11,16 @@ import ( "github.com/stretchr/testify/require" ) -func TestBundlePythonWheelBuild(t *testing.T) { +func TestPythonWheelBuild(t *testing.T) { ctx := context.Background() - b, err := bundle.Load(ctx, "./python_wheel") + b, err := bundle.Load(ctx, "./python_wheel/python_wheel") require.NoError(t, err) m := phases.Build() err = bundle.Apply(ctx, b, m) require.NoError(t, err) - matches, err := filepath.Glob("python_wheel/my_test_code/dist/my_test_code-*.whl") + matches, err := filepath.Glob("./python_wheel/python_wheel/my_test_code/dist/my_test_code-*.whl") require.NoError(t, err) require.Equal(t, 1, len(matches)) @@ -29,16 +29,16 @@ func TestBundlePythonWheelBuild(t *testing.T) { require.NoError(t, err) } -func TestBundlePythonWheelBuildAutoDetect(t *testing.T) { +func TestPythonWheelBuildAutoDetect(t *testing.T) { ctx := context.Background() - b, err := bundle.Load(ctx, "./python_wheel_no_artifact") + b, err := bundle.Load(ctx, "./python_wheel/python_wheel_no_artifact") require.NoError(t, err) m := phases.Build() err = bundle.Apply(ctx, b, m) require.NoError(t, err) - matches, err := filepath.Glob("python_wheel/my_test_code/dist/my_test_code-*.whl") + matches, err := filepath.Glob("./python_wheel/python_wheel_no_artifact/dist/my_test_code-*.whl") require.NoError(t, err) require.Equal(t, 1, len(matches)) @@ -47,9 +47,9 @@ func TestBundlePythonWheelBuildAutoDetect(t *testing.T) { require.NoError(t, err) } -func TestBundlePythonWheelWithDBFSLib(t *testing.T) { +func TestPythonWheelWithDBFSLib(t *testing.T) { ctx := context.Background() - b, err := bundle.Load(ctx, "./python_wheel_dbfs_lib") + b, err := bundle.Load(ctx, "./python_wheel/python_wheel_dbfs_lib") require.NoError(t, err) m := phases.Build() @@ -61,9 +61,9 @@ func TestBundlePythonWheelWithDBFSLib(t *testing.T) { require.NoError(t, err) } -func TestBundlePythonWheelBuildNoBuildJustUpload(t *testing.T) { +func TestPythonWheelBuildNoBuildJustUpload(t *testing.T) { ctx := context.Background() - b, err := bundle.Load(ctx, "./python_wheel_no_artifact_no_setup") + b, err := bundle.Load(ctx, "./python_wheel/python_wheel_no_artifact_no_setup") require.NoError(t, err) m := phases.Build()