Merge pull request #13 from databus23/patch-2

Do not require GITHUB_TOKEN for enterprise setups
This commit is contained in:
Linda_pp 2018-05-20 21:50:52 +09:00 committed by GitHub
commit c7abcd03e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 14 deletions

View File

@ -2,7 +2,6 @@ package selfupdate
import (
"context"
"errors"
"net/http"
"os"
@ -56,9 +55,6 @@ func NewUpdater(config Config) (*Updater, error) {
return &Updater{client, ctx}, nil
}
if token == "" {
return nil, errors.New("GitHub API token cannot be empty when releases are hosted on GitHub Enterprise instance")
}
u := config.EnterpriseUploadURL
if u == "" {
u = config.EnterpriseBaseURL

View File

@ -61,16 +61,6 @@ func TestGitHubEnterpriseClient(t *testing.T) {
}
}
func TestGitHubEnterpriseClientWithoutToken(t *testing.T) {
token := os.Getenv("GITHUB_TOKEN")
defer os.Setenv("GITHUB_TOKEN", token)
os.Setenv("GITHUB_TOKEN", "")
_, err := NewUpdater(Config{EnterpriseBaseURL: "https://github.company.com/api/v3/"})
if err == nil {
t.Fatal("Error should be reported because of empty token")
}
}
func TestGitHubEnterpriseClientInvalidURL(t *testing.T) {
_, err := NewUpdater(Config{APIToken: "hogehoge", EnterpriseBaseURL: ":this is not a URL"})
if err == nil {