|
|
@ -6,6 +6,7 @@ |
|
|
package github |
|
|
package github |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
|
|
|
"fmt" |
|
|
"testing" |
|
|
"testing" |
|
|
"time" |
|
|
"time" |
|
|
) |
|
|
) |
|
|
@ -77,3 +78,50 @@ func TestStringify(t *testing.T) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Directly test the String() methods on various GitHub types. We don't do an
|
|
|
|
|
|
// exaustive test of all the various field types, since TestStringify() above
|
|
|
|
|
|
// takes care of that. Rather, we just make sure that Stringify() is being
|
|
|
|
|
|
// used to build the strings, which we do by verifying that pointers are
|
|
|
|
|
|
// stringified as their underlying value.
|
|
|
|
|
|
func TestString(t *testing.T) { |
|
|
|
|
|
var tests = []struct { |
|
|
|
|
|
in interface{} |
|
|
|
|
|
out string |
|
|
|
|
|
}{ |
|
|
|
|
|
{Event{ID: String("1")}, `github.Event{ID:"1"}`}, |
|
|
|
|
|
{PushEvent{PushID: Int(1)}, `github.PushEvent{PushID:1}`}, |
|
|
|
|
|
{PushEventCommit{SHA: String("s")}, `github.PushEventCommit{SHA:"s"}`}, |
|
|
|
|
|
{Gist{ID: String("1")}, `github.Gist{ID:"1", Files:map[]}`}, |
|
|
|
|
|
{GistFile{Size: Int(1)}, `github.GistFile{Size:1}`}, |
|
|
|
|
|
{GistComment{ID: Int(1)}, `github.GistComment{ID:1}`}, |
|
|
|
|
|
{Commit{SHA: String("s")}, `github.Commit{SHA:"s"}`}, |
|
|
|
|
|
{CommitAuthor{Name: String("n")}, `github.CommitAuthor{Name:"n"}`}, |
|
|
|
|
|
{Tree{SHA: String("s")}, `github.Tree{SHA:"s"}`}, |
|
|
|
|
|
{TreeEntry{SHA: String("s")}, `github.TreeEntry{SHA:"s"}`}, |
|
|
|
|
|
{Issue{Number: Int(1)}, `github.Issue{Number:1}`}, |
|
|
|
|
|
{IssueComment{ID: Int(1)}, `github.IssueComment{ID:1}`}, |
|
|
|
|
|
{Label{Name: String("l")}, "l"}, |
|
|
|
|
|
{Organization{ID: Int(1)}, `github.Organization{ID:1}`}, |
|
|
|
|
|
{Team{ID: Int(1)}, `github.Team{ID:1}`}, |
|
|
|
|
|
{PullRequest{Number: Int(1)}, `github.PullRequest{Number:1}`}, |
|
|
|
|
|
{PullRequestComment{ID: Int(1)}, `github.PullRequestComment{ID:1}`}, |
|
|
|
|
|
{Repository{ID: Int(1)}, `github.Repository{ID:1}`}, |
|
|
|
|
|
{RepositoryComment{ID: Int(1)}, `github.RepositoryComment{ID:1}`}, |
|
|
|
|
|
{WebHookPayload{Ref: String("r")}, `github.WebHookPayload{Ref:"r"}`}, |
|
|
|
|
|
{WebHookCommit{ID: String("1")}, `github.WebHookCommit{ID:"1"}`}, |
|
|
|
|
|
{WebHookAuthor{Name: String("n")}, `github.WebHookAuthor{Name:"n"}`}, |
|
|
|
|
|
{Hook{ID: Int(1)}, `github.Hook{Config:map[], ID:1}`}, |
|
|
|
|
|
{RepoStatus{ID: Int(1)}, `github.RepoStatus{ID:1}`}, |
|
|
|
|
|
{CodeResult{Name: String("n")}, `github.CodeResult{Name:"n"}`}, |
|
|
|
|
|
{User{ID: Int(1)}, `github.User{ID:1}`}, |
|
|
|
|
|
{Key{ID: Int(1)}, `github.Key{ID:1}`}, |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for i, tt := range tests { |
|
|
|
|
|
s := tt.in.(fmt.Stringer).String() |
|
|
|
|
|
if s != tt.out { |
|
|
|
|
|
t.Errorf("%d. String() => %q, want %q", i, tt.in, tt.out) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |