mirror of https://github.com/databricks/cli.git
fix test on github actions
This commit is contained in:
parent
5d8613b21b
commit
749da47c99
|
@ -8,6 +8,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/databrickslabs/terraform-provider-databricks/clusters"
|
"github.com/databrickslabs/terraform-provider-databricks/clusters"
|
||||||
"github.com/ghodss/yaml"
|
"github.com/ghodss/yaml"
|
||||||
|
@ -135,6 +136,17 @@ func getGitOrigin() (*url.URL, error) {
|
||||||
return gitUrls.Parse(url.Value())
|
return gitUrls.Parse(url.Value())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GitRepositoryName returns repository name as last path entry from detected
|
||||||
|
// git repository up the tree or returns error if it fails to do so.
|
||||||
|
func GitRepositoryName() (string, error) {
|
||||||
|
origin, err := getGitOrigin()
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
base := path.Base(origin.Path)
|
||||||
|
return strings.ReplaceAll(base, ".git", ""), nil
|
||||||
|
}
|
||||||
|
|
||||||
func findDirWithLeaf(leaf string) (string, error) {
|
func findDirWithLeaf(leaf string) (string, error) {
|
||||||
dir, err := os.Getwd()
|
dir, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -3,7 +3,6 @@ package project
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
@ -30,9 +29,9 @@ func TestFindProjectRootInRoot(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetGitOrigin(t *testing.T) {
|
func TestGetGitOrigin(t *testing.T) {
|
||||||
origin, err := getGitOrigin()
|
this, err := GitRepositoryName()
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, "bricks.git", path.Base(origin.Path))
|
assert.Equal(t, "bricks", this)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLoadProjectConf(t *testing.T) {
|
func TestLoadProjectConf(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue