mirror of https://github.com/databricks/cli.git
move leaf_test.go to info_test.go
This commit is contained in:
parent
2e102b7c1a
commit
8b5bb37019
|
@ -0,0 +1,38 @@
|
|||
package git
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestFindLeafInTree(t *testing.T) {
|
||||
wd, err := os.Getwd()
|
||||
require.NoError(t, err)
|
||||
|
||||
root := filepath.Join(wd, "..", "..")
|
||||
|
||||
// Find from working directory should work.
|
||||
{
|
||||
out, err := FindLeafInTree(wd, ".git")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, root, out)
|
||||
}
|
||||
|
||||
// Find from project root itself should work.
|
||||
{
|
||||
out, err := FindLeafInTree(root, ".git")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, root, out)
|
||||
}
|
||||
|
||||
// Find for something that doesn't exist should work.
|
||||
{
|
||||
out, err := FindLeafInTree(root, "this-leaf-doesnt-exist-anywhere")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "", out)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue