Skip to content

Commit

Permalink
Merge pull request #130 from JehandadK/doc/upd-readme
Browse files Browse the repository at this point in the history
Allow use of ENV Varaibles to run tests which upload to github
  • Loading branch information
Songmu authored Jun 15, 2021
2 parents d43a5d2 + be0a17b commit 9ccb9be
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
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

0 comments on commit 9ccb9be

Please sign in to comment.