mirror of
https://github.com/MedzikUser/go-github-selfupdate.git
synced 2024-08-15 03:25:29 +00:00
add tests to create an updater instance for GitHub Enterprise
This commit is contained in:
parent
f637165ab7
commit
1265b4826d
1 changed files with 40 additions and 0 deletions
|
@ -18,3 +18,43 @@ func TestGitHubTokenEnv(t *testing.T) {
|
||||||
t.Error("Failed to initialize updater with API token config")
|
t.Error("Failed to initialize updater with API token config")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGitHubEnterpriseClient(t *testing.T) {
|
||||||
|
url := "https://github.company.com/api/v3/"
|
||||||
|
up, err := NewUpdater(Config{APIToken: "hogehoge", EnterpriseBaseURL: url})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if up.api.BaseURL.String() != url {
|
||||||
|
t.Error("Base URL was set to", up.api.BaseURL, ", want", url)
|
||||||
|
}
|
||||||
|
if up.api.UploadURL.String() != url {
|
||||||
|
t.Error("Upload URL was set to", up.api.UploadURL, ", want", url)
|
||||||
|
}
|
||||||
|
|
||||||
|
url2 := "https://upload.github.company.com/api/v3/"
|
||||||
|
up, err = NewUpdater(Config{
|
||||||
|
APIToken: "hogehoge",
|
||||||
|
EnterpriseBaseURL: url,
|
||||||
|
EnterpriseUploadURL: url2,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if up.api.BaseURL.String() != url {
|
||||||
|
t.Error("Base URL was set to", up.api.BaseURL, ", want", url)
|
||||||
|
}
|
||||||
|
if up.api.UploadURL.String() != url2 {
|
||||||
|
t.Error("Upload URL was set to", up.api.UploadURL, ", want", url2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue