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)
|
2022-05-23 09:46:37 +00:00
|
|
|
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)
|
|
|
|
|
2022-05-23 09:46:37 +00:00
|
|
|
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)
|
2022-05-23 09:46:37 +00:00
|
|
|
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
|
|
|
}
|