38 lines
707 B
Go
38 lines
707 B
Go
package fixtures
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestGetProjectRoot(t *testing.T) {
|
|
t.Run("default", func(t *testing.T) {
|
|
root := getProjectRoot()
|
|
assert.True(t, doesFileExist(filepath.Join(root, "go.sum")))
|
|
})
|
|
|
|
t.Run("subdir", func(t *testing.T) {
|
|
root1 := getProjectRoot()
|
|
err := os.Chdir(filepath.Join(root1, "src/rauc"))
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
root := getProjectRoot()
|
|
assert.True(t, doesFileExist(filepath.Join(root, "go.sum")))
|
|
})
|
|
}
|
|
|
|
func TestCdProjectRoot(t *testing.T) {
|
|
CdProjectRoot()
|
|
err := os.Chdir("src/rauc")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
CdProjectRoot()
|
|
assert.True(t, doesFileExist("go.sum"))
|
|
}
|