Skip to content

Commit

Permalink
test: add test for Format.All()
Browse files Browse the repository at this point in the history
  • Loading branch information
MH4GF committed Oct 26, 2023
1 parent 3222445 commit 490504f
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions lib/format_test.go
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)
}
}

0 comments on commit 490504f

Please sign in to comment.