Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit 3b75e0c

Browse files
committed
add tests for NewCommitIterCTime and NewCommitIterBSF
Signed-off-by: Saeed Rasooli <saeed.gnu@gmail.com>
1 parent dad9207 commit 3b75e0c

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed

plumbing/object/commit_walker_test.go

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,99 @@ func (s *CommitWalkerSuite) TestCommitPostIteratorWithIgnore(c *C) {
132132
c.Assert(commit.Hash.String(), Equals, expected[i])
133133
}
134134
}
135+
136+
func (s *CommitWalkerSuite) TestCommitCTimeIterator(c *C) {
137+
commit := s.commit(c, s.Fixture.Head)
138+
139+
var commits []*Commit
140+
NewCommitIterCTime(commit, nil, nil).ForEach(func(c *Commit) error {
141+
commits = append(commits, c)
142+
return nil
143+
})
144+
145+
c.Assert(commits, HasLen, 8)
146+
147+
expected := []string{
148+
"6ecf0ef2c2dffb796033e5a02219af86ec6584e5", // 2015-04-05T23:30:47+02:00
149+
"918c48b83bd081e863dbe1b80f8998f058cd8294", // 2015-03-31T13:56:18+02:00
150+
"af2d6a6954d532f8ffb47615169c8fdf9d383a1a", // 2015-03-31T13:51:51+02:00
151+
"1669dce138d9b841a518c64b10914d88f5e488ea", // 2015-03-31T13:48:14+02:00
152+
"a5b8b09e2f8fcb0bb99d3ccb0958157b40890d69", // 2015-03-31T13:47:14+02:00
153+
"35e85108805c84807bc66a02d91535e1e24b38b9", // 2015-03-31T13:46:24+02:00
154+
"b8e471f58bcbca63b07bda20e428190409c2db47", // 2015-03-31T13:44:52+02:00
155+
"b029517f6300c2da0f4b651b8642506cd6aaf45d", // 2015-03-31T13:42:21+02:00
156+
}
157+
for i, commit := range commits {
158+
c.Assert(commit.Hash.String(), Equals, expected[i])
159+
}
160+
}
161+
162+
func (s *CommitWalkerSuite) TestCommitCTimeIteratorWithIgnore(c *C) {
163+
commit := s.commit(c, s.Fixture.Head)
164+
165+
var commits []*Commit
166+
NewCommitIterCTime(commit, nil, []plumbing.Hash{
167+
plumbing.NewHash("af2d6a6954d532f8ffb47615169c8fdf9d383a1a"),
168+
}).ForEach(func(c *Commit) error {
169+
commits = append(commits, c)
170+
return nil
171+
})
172+
173+
c.Assert(commits, HasLen, 2)
174+
175+
expected := []string{
176+
"6ecf0ef2c2dffb796033e5a02219af86ec6584e5",
177+
"918c48b83bd081e863dbe1b80f8998f058cd8294",
178+
}
179+
for i, commit := range commits {
180+
c.Assert(commit.Hash.String(), Equals, expected[i])
181+
}
182+
}
183+
184+
func (s *CommitWalkerSuite) TestCommitBSFIterator(c *C) {
185+
commit := s.commit(c, s.Fixture.Head)
186+
187+
var commits []*Commit
188+
NewCommitIterBSF(commit, nil, nil).ForEach(func(c *Commit) error {
189+
commits = append(commits, c)
190+
return nil
191+
})
192+
193+
c.Assert(commits, HasLen, 8)
194+
195+
expected := []string{
196+
"6ecf0ef2c2dffb796033e5a02219af86ec6584e5",
197+
"918c48b83bd081e863dbe1b80f8998f058cd8294",
198+
"af2d6a6954d532f8ffb47615169c8fdf9d383a1a",
199+
"1669dce138d9b841a518c64b10914d88f5e488ea",
200+
"35e85108805c84807bc66a02d91535e1e24b38b9",
201+
"a5b8b09e2f8fcb0bb99d3ccb0958157b40890d69",
202+
"b029517f6300c2da0f4b651b8642506cd6aaf45d",
203+
"b8e471f58bcbca63b07bda20e428190409c2db47",
204+
}
205+
for i, commit := range commits {
206+
c.Assert(commit.Hash.String(), Equals, expected[i])
207+
}
208+
}
209+
210+
func (s *CommitWalkerSuite) TestCommitBSFIteratorWithIgnore(c *C) {
211+
commit := s.commit(c, s.Fixture.Head)
212+
213+
var commits []*Commit
214+
NewCommitIterBSF(commit, nil, []plumbing.Hash{
215+
plumbing.NewHash("af2d6a6954d532f8ffb47615169c8fdf9d383a1a"),
216+
}).ForEach(func(c *Commit) error {
217+
commits = append(commits, c)
218+
return nil
219+
})
220+
221+
c.Assert(commits, HasLen, 2)
222+
223+
expected := []string{
224+
"6ecf0ef2c2dffb796033e5a02219af86ec6584e5",
225+
"918c48b83bd081e863dbe1b80f8998f058cd8294",
226+
}
227+
for i, commit := range commits {
228+
c.Assert(commit.Hash.String(), Equals, expected[i])
229+
}
230+
}

0 commit comments

Comments
 (0)