Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow use of ENV Varaibles to run tests which upload to github #130

Merged
merged 2 commits into from
Jun 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ $ go get -u github.com/tcnksm/ghr
2. Create a feature branch
3. Commit your changes
4. Rebase your local changes against the master branch
5. Run test suite with the `make test` command and confirm that it passes
5. Run test suite with the `make test` command and confirm that it passes using correct variables e.g. `GITHUB_TOKEN=$GITHUB_TOKEN TEST_REPO_OWNER=tcnksm TEST_REPO_NAME=ghr make test`
6. Run `gofmt -s -w .`
7. Create new Pull Request

Expand Down
20 changes: 20 additions & 0 deletions github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,30 @@ import (
)

const (
// EnvRepoOwner is an environment var for the repository owner on which the github release test is performed
EnvRepoOwner = "TEST_REPO_OWNER"
// EnvRepoName is an environment var for the name of repository on which the github release test is performed
EnvRepoName = "TEST_REPO_NAME"
)

var (
TestOwner = "ghtools"
TestRepo = "github-api-test"
)

func TestMain(m *testing.M) {
if owner := os.Getenv(EnvRepoOwner); owner != "" {
TestOwner = owner
}

if repo := os.Getenv(EnvRepoName); repo != "" {
TestRepo = repo
}

code := m.Run()
os.Exit(code)
}

func testGithubClient(t *testing.T) GitHub {
token := os.Getenv(EnvGitHubToken)
client, err := NewGitHubClient(TestOwner, TestRepo, token, defaultBaseURL)
Expand Down