move leaf_test.go to info_test.go

This commit is contained in:
Denis Bilenko 2024-12-09 17:43:36 +01:00
parent 2e102b7c1a
commit 8b5bb37019
1 changed files with 38 additions and 0 deletions

38
libs/git/info_test.go Normal file
View File

@ -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)
}
}