本文整理匯總了Golang中k8s/io/contrib/mungegithub/github/testing.Commits函數的典型用法代碼示例。如果您正苦於以下問題:Golang Commits函數的具體用法?Golang Commits怎麽用?Golang Commits使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Commits函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Commits
// Commits returns a slice of github.RepositoryCommit of len==3 which
// happened at times 7, 8, 9
func Commits() []github.RepositoryCommit {
return github_test.Commits(3, 7)
}
示例2: TestGetLastModified
func TestGetLastModified(t *testing.T) {
tests := []struct {
commits []github.RepositoryCommit
expectedTime *time.Time
}{
{
commits: github_test.Commits(1, 10),
expectedTime: timePtr(time.Unix(10, 0)),
},
{
// remember the order of github_test.Commits() is non-deterministic
commits: github_test.Commits(3, 10),
expectedTime: timePtr(time.Unix(12, 0)),
},
{
// so this is probably not quite the same test...
commits: github_test.Commits(3, 8),
expectedTime: timePtr(time.Unix(10, 0)),
},
{
// We can't represent the same time in 2 commits using github_test.Commits()
commits: []github.RepositoryCommit{
{
SHA: stringPtr("mysha1"),
Commit: &github.Commit{
SHA: stringPtr("mysha1"),
Committer: &github.CommitAuthor{
Date: timePtr(time.Unix(9, 0)),
},
},
},
{
SHA: stringPtr("mysha2"),
Commit: &github.Commit{
SHA: stringPtr("mysha2"),
Committer: &github.CommitAuthor{
Date: timePtr(time.Unix(10, 0)),
},
},
},
{
SHA: stringPtr("mysha3"),
Commit: &github.Commit{
SHA: stringPtr("mysha3"),
Committer: &github.CommitAuthor{
Date: timePtr(time.Unix(9, 0)),
},
},
},
},
expectedTime: timePtr(time.Unix(10, 0)),
},
}
for _, test := range tests {
client, server, _ := github_test.InitServer(t, nil, nil, nil, test.commits, nil, nil)
config := &Config{}
config.Org = "o"
config.Project = "r"
config.SetClient(client)
obj := &MungeObject{
config: config,
Issue: github_test.Issue("bob", 1, nil, true),
}
ts := obj.LastModifiedTime()
if !ts.Equal(*test.expectedTime) {
t.Errorf("expected: %v, saw: %v for: %v", test.expectedTime, ts, test)
}
server.Close()
}
}