test(releaser/github): test New func

This commit is contained in:
fwiedmann
2019-07-28 23:00:08 +02:00
parent a15eaa597a
commit e170ca9885

View File

@@ -0,0 +1,44 @@
package github_test
import (
"github.com/Nightapes/go-semantic-release/internal/releaser/github"
"github.com/Nightapes/go-semantic-release/pkg/config"
"github.com/stretchr/testify/assert"
"os"
"testing"
)
type testDoubleNew struct {
config config.GitHubProvider
valid bool
}
var doublesNew = []testDoubleNew{
testDoubleNew{config: config.GitHubProvider{
Repo: "foo",
User: "bar",
},
valid: true,
},
testDoubleNew{config: config.GitHubProvider{
Repo: "foo",
User: "bar",
},
valid: false,
},
}
func TestNew(t *testing.T) {
for _, testOject := range doublesNew {
if testOject.valid {
os.Setenv("GITHUB_ACCESS_TOKEN", "XXX")
}
_, err := github.New(&testOject.config)
assert.Equal(t, testOject.valid, err == nil)
os.Unsetenv("GITHUB_ACCESS_TOKEN")
}
}