test(ci services): add test for travis

This commit is contained in:
Nightapes
2019-07-16 20:26:57 +02:00
parent 13afcea8a0
commit c86ad684c6
5 changed files with 95 additions and 5 deletions

View File

@@ -10,7 +10,7 @@ import (
type Travis struct{}
//Detect if on travis
func (t Travis) Detect() (*ProviderConfig, error) {
func (t Travis) detect() (*ProviderConfig, error) {
if _, exists := os.LookupEnv("TRAVIS"); !exists {
return nil, fmt.Errorf("not running on travis")
@@ -19,11 +19,13 @@ func (t Travis) Detect() (*ProviderConfig, error) {
isPR := false
value := os.Getenv("TRAVIS_PULL_REQUEST")
pr := ""
if value == "false" {
log.Debugf("TRAVIS_PULL_REQUEST=%s, not running on pr", value)
} else {
isPR = true
pr = value
}
return &ProviderConfig{
@@ -34,6 +36,7 @@ func (t Travis) Detect() (*ProviderConfig, error) {
BuildURL: os.Getenv("TRAVIS_BUILD_WEB_URL"),
Branch: os.Getenv("TRAVIS_BRANCH"),
IsPR: isPR,
PR: pr,
PRBranch: os.Getenv("TRAVIS_PULL_REQUEST_BRANCH"),
}, nil
}