github.com/Theta-Dev/Talon@v0.0.0-20211018130634-ff179e19fa9a/src/fixtures/testutil_test.go (about) 1 package fixtures 2 3 import ( 4 "os" 5 "path/filepath" 6 "testing" 7 8 "code.thetadev.de/ThetaDev/gotry/try" 9 "github.com/stretchr/testify/assert" 10 ) 11 12 func TestGetProjectRoot(t *testing.T) { 13 t.Run("default", func(t *testing.T) { 14 root := getProjectRoot() 15 assert.True(t, doesFileExist(filepath.Join(root, "go.sum"))) 16 }) 17 18 t.Run("subdir", func(t *testing.T) { 19 root1 := getProjectRoot() 20 try.Check(os.Chdir(filepath.Join(root1, "src/database"))) 21 22 root := getProjectRoot() 23 assert.True(t, doesFileExist(filepath.Join(root, "go.sum"))) 24 }) 25 } 26 27 func TestCdProjectRoot(t *testing.T) { 28 CdProjectRoot() 29 try.Check(os.Chdir("src/database")) 30 CdProjectRoot() 31 assert.True(t, doesFileExist("go.sum")) 32 }