2022-11-28 09:59:43 +00:00
|
|
|
package config_tests
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
|
2023-05-16 16:35:39 +00:00
|
|
|
"github.com/databricks/cli/bundle"
|
|
|
|
"github.com/databricks/cli/bundle/config/mutator"
|
2022-11-28 09:59:43 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func load(t *testing.T, path string) *bundle.Bundle {
|
2023-08-11 12:28:05 +00:00
|
|
|
ctx := context.Background()
|
|
|
|
b, err := bundle.Load(ctx, path)
|
2022-11-28 09:59:43 +00:00
|
|
|
require.NoError(t, err)
|
2023-08-11 12:28:05 +00:00
|
|
|
err = bundle.Apply(ctx, b, bundle.Seq(mutator.DefaultMutators()...))
|
2022-11-28 09:59:43 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
2023-08-17 15:22:32 +00:00
|
|
|
func loadTarget(t *testing.T, path, env string) *bundle.Bundle {
|
2022-11-28 09:59:43 +00:00
|
|
|
b := load(t, path)
|
2023-08-17 15:22:32 +00:00
|
|
|
err := bundle.Apply(context.Background(), b, mutator.SelectTarget(env))
|
2022-11-28 09:59:43 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
return b
|
|
|
|
}
|