-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #116 from MH4GF/refactor-settings-and-format-2
refactor(lib): Remove environment variable dependencies from `Settings.Init()` and `Format.All()`
- Loading branch information
Showing
6 changed files
with
66 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package lib_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/google/go-github/github" | ||
"github.com/masutaka/github-nippou/lib" | ||
) | ||
|
||
func TestFormatAll(t *testing.T) { | ||
issue := github.Issue{ | ||
State: github.String("closed"), | ||
Title: github.String("イベントを取得できないことがある"), | ||
User: &github.User{Login: github.String("masutaka")}, | ||
HTMLURL: github.String("https://github.com/masutaka/github-nippou/issues/1"), | ||
} | ||
pr := github.PullRequest{ | ||
State: github.String("closed"), | ||
Title: github.String("Bundle Update on 2015-10-04"), | ||
User: &github.User{Login: github.String("deppbot")}, | ||
HTMLURL: github.String("https://github.com/masutaka/github-nippou/pull/31"), | ||
Merged: github.Bool(true), | ||
} | ||
lines := lib.Lines{ | ||
lib.NewLineByIssue("masutaka/github-nippou", issue), | ||
lib.NewLineByPullRequest("masutaka/github-nippou", pr), | ||
} | ||
settings := lib.Settings{} | ||
settings.Init("", "") | ||
|
||
ctx := context.Background() | ||
f := lib.NewFormat(ctx, nil, settings, false) | ||
|
||
result, err := f.All(lines) | ||
if err != nil { | ||
t.Errorf("unexpected error: %v", err) | ||
} | ||
|
||
expected := ` | ||
### masutaka/github-nippou | ||
* [イベントを取得できないことがある](https://github.com/masutaka/github-nippou/issues/1) by @[masutaka](https://github.com/masutaka) **closed!** | ||
* [Bundle Update on 2015-10-04](https://github.com/masutaka/github-nippou/pull/31) by @[deppbot](https://github.com/deppbot) **merged!** | ||
` | ||
|
||
if result != expected { | ||
t.Errorf("unexpected result: got %q, want %q", result, expected) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters