SEBRAUC/src/fixtures/testutil_test.go
Theta-Dev 51eb9c0cac
All checks were successful
continuous-integration/drone/push Build is passing
finished uploader component
2021-11-21 01:31:38 +01:00

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