2024-10-01 17:46:53 +00:00
|
|
|
package bundletest
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/databricks/cli/bundle"
|
|
|
|
"github.com/databricks/cli/libs/diag"
|
|
|
|
"github.com/databricks/cli/libs/dyn"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Mutate(t *testing.T, b *bundle.Bundle, f func(v dyn.Value) (dyn.Value, error)) {
|
2024-10-01 18:22:53 +00:00
|
|
|
diags := bundle.ApplyFunc(context.Background(), b, func(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {
|
2024-10-01 17:46:53 +00:00
|
|
|
err := b.Config.Mutate(f)
|
|
|
|
require.NoError(t, err)
|
|
|
|
return nil
|
|
|
|
})
|
2024-10-01 18:22:53 +00:00
|
|
|
require.NoError(t, diags.Error())
|
2024-10-01 17:46:53 +00:00
|
|
|
}
|