2022-11-18 09:57:31 +00:00
|
|
|
package mutator_test
|
|
|
|
|
|
|
|
import (
|
2022-11-28 09:59:43 +00:00
|
|
|
"context"
|
2022-11-18 09:57:31 +00:00
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
|
2023-05-16 16:35:39 +00:00
|
|
|
"github.com/databricks/cli/bundle"
|
|
|
|
"github.com/databricks/cli/bundle/config"
|
|
|
|
"github.com/databricks/cli/bundle/config/mutator"
|
2022-11-18 09:57:31 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestProcessInclude(t *testing.T) {
|
2022-11-28 09:59:43 +00:00
|
|
|
bundle := &bundle.Bundle{
|
|
|
|
Config: config.Root{
|
|
|
|
Path: t.TempDir(),
|
|
|
|
Workspace: config.Workspace{
|
|
|
|
Host: "foo",
|
|
|
|
},
|
2022-11-18 09:57:31 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
relPath := "./file.yml"
|
2022-11-28 09:59:43 +00:00
|
|
|
fullPath := filepath.Join(bundle.Config.Path, relPath)
|
2022-11-18 09:57:31 +00:00
|
|
|
f, err := os.Create(fullPath)
|
|
|
|
require.NoError(t, err)
|
|
|
|
fmt.Fprint(f, "workspace:\n host: bar\n")
|
|
|
|
f.Close()
|
|
|
|
|
2022-11-28 09:59:43 +00:00
|
|
|
assert.Equal(t, "foo", bundle.Config.Workspace.Host)
|
2023-05-24 12:45:19 +00:00
|
|
|
err = mutator.ProcessInclude(fullPath, relPath).Apply(context.Background(), bundle)
|
2022-11-18 09:57:31 +00:00
|
|
|
require.NoError(t, err)
|
2022-11-28 09:59:43 +00:00
|
|
|
assert.Equal(t, "bar", bundle.Config.Workspace.Host)
|
2022-11-18 09:57:31 +00:00
|
|
|
}
|