databricks-cli/libs/template/materialize_test.go

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

33 lines
803 B
Go
Raw Normal View History

package template
import (
"context"
"fmt"
"os"
"testing"
"github.com/databricks/cli/cmd/root"
"github.com/databricks/databricks-sdk-go"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestMaterializeForNonTemplateDirectory(t *testing.T) {
tmpDir := t.TempDir()
w, err := databricks.NewWorkspaceClient(&databricks.Config{})
require.NoError(t, err)
ctx := root.SetWorkspaceClient(context.Background(), w)
2024-12-27 06:05:04 +00:00
tmpl := Template{
TemplateOpts: TemplateOpts{
ConfigFilePath: "",
TemplateFS: os.DirFS(tmpDir),
OutputFiler: nil,
},
}
// Try to materialize a non-template directory.
2024-12-27 06:05:04 +00:00
err = tmpl.Materialize(ctx)
assert.EqualError(t, err, fmt.Sprintf("not a bundle template: expected to find a template schema file at %s", schemaFileName))
}