Merge pull request #13 from databus23/patch-2
Do not require GITHUB_TOKEN for enterprise setups
This commit is contained in:
commit
c7abcd03e1
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue