WebUI/src/fixtures/testutil_test.go
Theta-Dev 60034b4815
All checks were successful
continuous-integration/drone/push Build is passing
add server base
2022-02-01 23:08:45 +01:00

46 lines
871 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/server"))
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/server")
if err != nil {
panic(err)
}
CdProjectRoot()
assert.True(t, doesFileExist("go.sum"))
}
func TestResetEnv(t *testing.T) {
os.Setenv("TSGRAINWEB_PORT", "8001")
ResetEnv()
_, exists := os.LookupEnv("TSGRAINWEB_PORT")
assert.False(t, exists)
}