|
@@ -361,6 +361,19 @@ func TestConfigurationOptionFormatDefault(t *testing.T) {
|
|
|
assert.Equal(t, opt.FormatDefault(), "0.5")
|
|
|
}
|
|
|
|
|
|
+func TestPrepareRunPlanTiny(t *testing.T) {
|
|
|
+ rootCommit, err := test.Repository.CommitObject(plumbing.NewHash(
|
|
|
+ "cce947b98a050c6d356bc6ba95030254914027b1"))
|
|
|
+ if err != nil {
|
|
|
+ t.Fatal(err)
|
|
|
+ }
|
|
|
+ plan := prepareRunPlan([]*object.Commit{rootCommit})
|
|
|
+ assert.Len(t, plan, 1)
|
|
|
+ assert.Equal(t, runActionCommit, plan[0].Action)
|
|
|
+ assert.Equal(t, 0, plan[0].Items[0])
|
|
|
+ assert.Equal(t, "cce947b98a050c6d356bc6ba95030254914027b1", plan[0].Commit.Hash.String())
|
|
|
+}
|
|
|
+
|
|
|
func TestPrepareRunPlanSmall(t *testing.T) {
|
|
|
cit, err := test.Repository.Log(&git.LogOptions{From: plumbing.ZeroHash})
|
|
|
if err != nil {
|
|
@@ -400,25 +413,25 @@ func TestPrepareRunPlanSmall(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
func TestPrepareRunPlanBig(t *testing.T) {
|
|
|
- cases := [][6]int {
|
|
|
- {2017, 8, 9, 0, 0, 0},
|
|
|
- {2017, 8, 10, 0, 0, 0},
|
|
|
- {2017, 8, 24, 1, 1, 1},
|
|
|
- {2017, 9, 19, 1-2, 1, 1},
|
|
|
- {2017, 9, 23, 1-2, 1, 1},
|
|
|
- {2017, 12, 8, 1, 1, 1},
|
|
|
- {2017, 12, 9, 1, 1, 1},
|
|
|
- {2017, 12, 10, 1, 1, 1},
|
|
|
- {2017, 12, 11, 2, 2, 2},
|
|
|
- {2017, 12, 19, 4, 4, 4},
|
|
|
- {2017, 12, 27, 4, 4, 4},
|
|
|
- {2018, 1, 10, 4, 4, 4},
|
|
|
- {2018, 1, 16, 4, 4, 4},
|
|
|
- {2018, 1, 18, 7, 6, 7},
|
|
|
- {2018, 1, 23, 8, 6, 8},
|
|
|
- {2018, 3, 12, 9, 7, 9},
|
|
|
- {2018, 5, 13, 9, 7, 9},
|
|
|
- {2018, 5, 16, 13, 9, 13},
|
|
|
+ cases := [][7]int {
|
|
|
+ {2017, 8, 9, 0, 0, 0, 0},
|
|
|
+ {2017, 8, 10, 0, 0, 0, 0},
|
|
|
+ {2017, 8, 24, 1, 1, 1, 1},
|
|
|
+ {2017, 9, 19, 1-2, 1, 1, 1},
|
|
|
+ {2017, 9, 23, 1-2, 1, 1, 1},
|
|
|
+ {2017, 12, 8, 1, 1, 1, 1},
|
|
|
+ {2017, 12, 9, 1, 1, 1, 1},
|
|
|
+ {2017, 12, 10, 1, 1, 1, 1},
|
|
|
+ {2017, 12, 11, 2, 2, 2, 2},
|
|
|
+ {2017, 12, 19, 4, 4, 4, 4},
|
|
|
+ {2017, 12, 27, 4, 4, 4, 4},
|
|
|
+ {2018, 1, 10, 4, 4, 4, 4},
|
|
|
+ {2018, 1, 16, 4, 4, 4, 4},
|
|
|
+ {2018, 1, 18, 7, 6, 7, 7},
|
|
|
+ {2018, 1, 23, 8, 6, 8, 8},
|
|
|
+ {2018, 3, 12, 9, 7, 9, 9},
|
|
|
+ {2018, 5, 13, 9, 7, 9, 9},
|
|
|
+ {2018, 5, 16, 13, 9, 13, 13},
|
|
|
}
|
|
|
for _, testCase := range cases {
|
|
|
cit, err := test.Repository.Log(&git.LogOptions{From: plumbing.ZeroHash})
|
|
@@ -449,6 +462,7 @@ func TestPrepareRunPlanBig(t *testing.T) {
|
|
|
numCommits := 0
|
|
|
numForks := 0
|
|
|
numMerges := 0
|
|
|
+ numDeletes := 0
|
|
|
for _, p := range plan {
|
|
|
switch p.Action {
|
|
|
case runActionCommit:
|
|
@@ -457,10 +471,13 @@ func TestPrepareRunPlanBig(t *testing.T) {
|
|
|
numForks++
|
|
|
case runActionMerge:
|
|
|
numMerges++
|
|
|
+ case runActionDelete:
|
|
|
+ numDeletes++
|
|
|
}
|
|
|
}
|
|
|
assert.Equal(t, numCommits, len(commits)+testCase[3], fmt.Sprintf("commits %v", testCase))
|
|
|
assert.Equal(t, numForks, testCase[4], fmt.Sprintf("forks %v", testCase))
|
|
|
assert.Equal(t, numMerges, testCase[5], fmt.Sprintf("merges %v", testCase))
|
|
|
+ assert.Equal(t, numMerges, testCase[6], fmt.Sprintf("deletes %v", testCase))
|
|
|
}
|
|
|
}
|