2020-05-27 18:55:44 +07:00
|
|
|
package suites
|
|
|
|
|
2020-11-28 07:06:42 +07:00
|
|
|
import (
|
2021-10-08 07:17:08 +07:00
|
|
|
"io/ioutil"
|
2020-11-28 07:06:42 +07:00
|
|
|
"os"
|
2021-10-08 07:17:08 +07:00
|
|
|
"path/filepath"
|
2020-11-28 07:06:42 +07:00
|
|
|
"strconv"
|
2021-10-08 07:17:08 +07:00
|
|
|
"strings"
|
2020-11-28 07:06:42 +07:00
|
|
|
)
|
|
|
|
|
2020-05-27 18:55:44 +07:00
|
|
|
// GetLoginBaseURL returns the URL of the login portal and the path prefix if specified.
|
|
|
|
func GetLoginBaseURL() string {
|
|
|
|
if PathPrefix != "" {
|
|
|
|
return LoginBaseURL + PathPrefix
|
|
|
|
}
|
|
|
|
|
|
|
|
return LoginBaseURL
|
|
|
|
}
|
2020-11-28 07:06:42 +07:00
|
|
|
|
|
|
|
// GetWebDriverPort returns the port to initialize the webdriver with.
|
|
|
|
func GetWebDriverPort() int {
|
|
|
|
driverPort := os.Getenv("CHROMEDRIVER_PORT")
|
|
|
|
if driverPort == "" {
|
|
|
|
driverPort = defaultChromeDriverPort
|
|
|
|
}
|
|
|
|
|
|
|
|
p, _ := strconv.Atoi(driverPort)
|
|
|
|
|
|
|
|
return p
|
|
|
|
}
|
2021-10-08 07:17:08 +07:00
|
|
|
|
|
|
|
func fixCoveragePath(path string, file os.FileInfo, err error) error {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if file.IsDir() {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
coverage, err := filepath.Match("*.json", file.Name())
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if coverage {
|
|
|
|
read, err := ioutil.ReadFile(path)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
wd, _ := os.Getwd()
|
|
|
|
ciPath := strings.TrimSuffix(wd, "internal/suites")
|
|
|
|
content := strings.ReplaceAll(string(read), "/node/src/app/", ciPath+"web/")
|
|
|
|
|
|
|
|
err = ioutil.WriteFile(path, []byte(content), 0)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|