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.
This commit is contained in:
Pieter Noordhuis 2024-03-21 11:37:05 +01:00 committed by GitHub
parent 0ef93c2502
commit f202596a6f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 12 additions and 38 deletions

View File

@ -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
}

View File

@ -1,4 +1,4 @@
package bundle package config_tests
import ( import (
"context" "context"

View File

@ -1,4 +1,4 @@
package bundle package config_tests
import ( import (
"context" "context"
@ -11,16 +11,16 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
func TestBundlePythonWheelBuild(t *testing.T) { func TestPythonWheelBuild(t *testing.T) {
ctx := context.Background() ctx := context.Background()
b, err := bundle.Load(ctx, "./python_wheel") b, err := bundle.Load(ctx, "./python_wheel/python_wheel")
require.NoError(t, err) require.NoError(t, err)
m := phases.Build() m := phases.Build()
err = bundle.Apply(ctx, b, m) err = bundle.Apply(ctx, b, m)
require.NoError(t, err) 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.NoError(t, err)
require.Equal(t, 1, len(matches)) require.Equal(t, 1, len(matches))
@ -29,16 +29,16 @@ func TestBundlePythonWheelBuild(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
} }
func TestBundlePythonWheelBuildAutoDetect(t *testing.T) { func TestPythonWheelBuildAutoDetect(t *testing.T) {
ctx := context.Background() 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) require.NoError(t, err)
m := phases.Build() m := phases.Build()
err = bundle.Apply(ctx, b, m) err = bundle.Apply(ctx, b, m)
require.NoError(t, err) 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.NoError(t, err)
require.Equal(t, 1, len(matches)) require.Equal(t, 1, len(matches))
@ -47,9 +47,9 @@ func TestBundlePythonWheelBuildAutoDetect(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
} }
func TestBundlePythonWheelWithDBFSLib(t *testing.T) { func TestPythonWheelWithDBFSLib(t *testing.T) {
ctx := context.Background() 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) require.NoError(t, err)
m := phases.Build() m := phases.Build()
@ -61,9 +61,9 @@ func TestBundlePythonWheelWithDBFSLib(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
} }
func TestBundlePythonWheelBuildNoBuildJustUpload(t *testing.T) { func TestPythonWheelBuildNoBuildJustUpload(t *testing.T) {
ctx := context.Background() 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) require.NoError(t, err)
m := phases.Build() m := phases.Build()