refactor: use regexp to get root path
This commit is contained in:
20
main_test.go
Normal file
20
main_test.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestRootDir(t *testing.T) {
|
||||
projectDirName := "go-root-dir"
|
||||
dir := RootDir(projectDirName)
|
||||
require.NotEmpty(t, dir)
|
||||
require.Equal(t, strings.Split(dir, "/")[len(strings.Split(dir, "/"))-1], projectDirName)
|
||||
}
|
||||
|
||||
func TestRootDirError(t *testing.T) {
|
||||
require.Empty(t, RootDir(""))
|
||||
require.Empty(t, RootDir("aaa"))
|
||||
}
|
||||
Reference in New Issue
Block a user