databricks-cli/project/config_test.go

41 lines
833 B
Go
Raw Normal View History

2022-05-14 17:55:00 +00:00
package project
import (
"fmt"
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestFindProjectRoot(t *testing.T) {
wd, _ := os.Getwd()
defer os.Chdir(wd)
err := os.Chdir("testdata/a/b/c")
2022-05-14 17:55:00 +00:00
assert.NoError(t, err)
root, err := findProjectRoot()
assert.NoError(t, err)
assert.Equal(t, fmt.Sprintf("%s/testdata", wd), root)
2022-05-14 17:55:00 +00:00
}
func TestFindProjectRootInRoot(t *testing.T) {
wd, _ := os.Getwd()
defer os.Chdir(wd)
err := os.Chdir("/tmp")
assert.NoError(t, err)
_, err = findProjectRoot()
assert.EqualError(t, err, "cannot find databricks.yml anywhere")
}
func TestLoadProjectConf(t *testing.T) {
wd, _ := os.Getwd()
defer os.Chdir(wd)
os.Chdir("testdata/a/b/c")
2022-05-14 17:55:00 +00:00
prj, err := loadProjectConf()
assert.NoError(t, err)
assert.Equal(t, "dev", prj.Name)
assert.True(t, prj.IsDevClusterJustReference())
2022-05-16 11:14:27 +00:00
}