2024-03-27 10:49:05 +00:00
|
|
|
package loader_test
|
2022-11-18 09:57:31 +00:00
|
|
|
|
|
|
|
import (
|
2022-11-28 09:59:43 +00:00
|
|
|
"context"
|
2022-11-18 09:57:31 +00:00
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
|
2023-05-16 16:35:39 +00:00
|
|
|
"github.com/databricks/cli/bundle"
|
|
|
|
"github.com/databricks/cli/bundle/config"
|
2024-03-27 10:49:05 +00:00
|
|
|
"github.com/databricks/cli/bundle/config/loader"
|
2022-11-18 09:57:31 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestProcessInclude(t *testing.T) {
|
2023-11-15 14:03:36 +00:00
|
|
|
b := &bundle.Bundle{
|
2024-03-27 10:49:05 +00:00
|
|
|
RootPath: "testdata",
|
2022-11-28 09:59:43 +00:00
|
|
|
Config: config.Root{
|
|
|
|
Workspace: config.Workspace{
|
|
|
|
Host: "foo",
|
|
|
|
},
|
2022-11-18 09:57:31 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2024-03-27 10:49:05 +00:00
|
|
|
m := loader.ProcessInclude(filepath.Join(b.RootPath, "host.yml"), "host.yml")
|
|
|
|
assert.Equal(t, "ProcessInclude(host.yml)", m.Name())
|
2022-11-18 09:57:31 +00:00
|
|
|
|
2024-03-27 10:49:05 +00:00
|
|
|
// Assert the host value prior to applying the mutator
|
2023-11-15 14:03:36 +00:00
|
|
|
assert.Equal(t, "foo", b.Config.Workspace.Host)
|
2024-03-27 10:49:05 +00:00
|
|
|
|
|
|
|
// Apply the mutator and assert that the host value has been updated
|
|
|
|
diags := bundle.Apply(context.Background(), b, m)
|
2024-03-25 14:18:47 +00:00
|
|
|
require.NoError(t, diags.Error())
|
2023-11-15 14:03:36 +00:00
|
|
|
assert.Equal(t, "bar", b.Config.Workspace.Host)
|
2022-11-18 09:57:31 +00:00
|
|
|
}
|