Skip to content

Commit 9ccb9be

Browse files
authored
Merge pull request #130 from JehandadK/doc/upd-readme
Allow use of ENV Varaibles to run tests which upload to github
2 parents d43a5d2 + be0a17b commit 9ccb9be

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ $ go get -u github.com/tcnksm/ghr
122122
2. Create a feature branch
123123
3. Commit your changes
124124
4. Rebase your local changes against the master branch
125-
5. Run test suite with the `make test` command and confirm that it passes
125+
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`
126126
6. Run `gofmt -s -w .`
127127
7. Create new Pull Request
128128

github_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,30 @@ import (
1414
)
1515

1616
const (
17+
// EnvRepoOwner is an environment var for the repository owner on which the github release test is performed
18+
EnvRepoOwner = "TEST_REPO_OWNER"
19+
// EnvRepoName is an environment var for the name of repository on which the github release test is performed
20+
EnvRepoName = "TEST_REPO_NAME"
21+
)
22+
23+
var (
1724
TestOwner = "ghtools"
1825
TestRepo = "github-api-test"
1926
)
2027

28+
func TestMain(m *testing.M) {
29+
if owner := os.Getenv(EnvRepoOwner); owner != "" {
30+
TestOwner = owner
31+
}
32+
33+
if repo := os.Getenv(EnvRepoName); repo != "" {
34+
TestRepo = repo
35+
}
36+
37+
code := m.Run()
38+
os.Exit(code)
39+
}
40+
2141
func testGithubClient(t *testing.T) GitHub {
2242
token := os.Getenv(EnvGitHubToken)
2343
client, err := NewGitHubClient(TestOwner, TestRepo, token, defaultBaseURL)

0 commit comments

Comments
 (0)