Skip to content

Commit 82c464c

Browse files
test: prevent ci variables from leaking into the test
1 parent b8ab3e1 commit 82c464c

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

pkg/condition/github_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package condition
22

33
import (
4+
"os"
45
"testing"
56

67
"github.com/stretchr/testify/assert"
78
)
89

910
func TestGithubValid(t *testing.T) {
1011
gha := GitHubActions{}
12+
os.Setenv("GITHUB_REF", "")
1113
err := gha.RunCondition(CIConfig{"defaultBranch": ""})
1214
assert.EqualError(t, err, "This test run is not running on a branch build.")
1315
}

pkg/condition/gitlab_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package condition
22

33
import (
4+
"os"
45
"testing"
56

67
"github.com/stretchr/testify/assert"
78
)
89

910
func TestGitlabValid(t *testing.T) {
1011
gl := GitLab{}
12+
os.Setenv("CI_COMMIT_BRANCH", "")
1113
err := gl.RunCondition(CIConfig{"defaultBranch": ""})
1214
assert.EqualError(t, err, "This test run is not running on a branch build.")
1315
}

pkg/condition/travis_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package condition
22

33
import (
4+
"os"
45
"testing"
56

67
"github.com/stretchr/testify/assert"
78
)
89

910
func TestTravisValid(t *testing.T) {
1011
travis := TravisCI{}
12+
os.Setenv("TRAVIS", "")
1113
err := travis.RunCondition(CIConfig{"token": "", "defaultBranch": "", "private": false})
1214
assert.EqualError(t, err, "semantic-release didn’t run on Travis CI and therefore a new version won’t be published.")
1315
}

0 commit comments

Comments
 (0)