|
|
@ -146,31 +146,42 @@ func TestCountRepoMilestones(t *testing.T) { |
|
|
|
assert.NoError(t, PrepareTestDatabase()) |
|
|
|
assert.NoError(t, PrepareTestDatabase()) |
|
|
|
test := func(repoID int64) { |
|
|
|
test := func(repoID int64) { |
|
|
|
repo := AssertExistsAndLoadBean(t, &Repository{ID: repoID}).(*Repository) |
|
|
|
repo := AssertExistsAndLoadBean(t, &Repository{ID: repoID}).(*Repository) |
|
|
|
assert.EqualValues(t, repo.NumMilestones, countRepoMilestones(x, repoID)) |
|
|
|
count, err := countRepoMilestones(x, repoID) |
|
|
|
|
|
|
|
assert.NoError(t, err) |
|
|
|
|
|
|
|
assert.EqualValues(t, repo.NumMilestones, count) |
|
|
|
} |
|
|
|
} |
|
|
|
test(1) |
|
|
|
test(1) |
|
|
|
test(2) |
|
|
|
test(2) |
|
|
|
test(3) |
|
|
|
test(3) |
|
|
|
assert.EqualValues(t, 0, countRepoMilestones(x, NonexistentID)) |
|
|
|
|
|
|
|
|
|
|
|
count, err := countRepoMilestones(x, NonexistentID) |
|
|
|
|
|
|
|
assert.NoError(t, err) |
|
|
|
|
|
|
|
assert.EqualValues(t, 0, count) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestCountRepoClosedMilestones(t *testing.T) { |
|
|
|
func TestCountRepoClosedMilestones(t *testing.T) { |
|
|
|
assert.NoError(t, PrepareTestDatabase()) |
|
|
|
assert.NoError(t, PrepareTestDatabase()) |
|
|
|
test := func(repoID int64) { |
|
|
|
test := func(repoID int64) { |
|
|
|
repo := AssertExistsAndLoadBean(t, &Repository{ID: repoID}).(*Repository) |
|
|
|
repo := AssertExistsAndLoadBean(t, &Repository{ID: repoID}).(*Repository) |
|
|
|
assert.EqualValues(t, repo.NumClosedMilestones, CountRepoClosedMilestones(repoID)) |
|
|
|
count, err := CountRepoClosedMilestones(repoID) |
|
|
|
|
|
|
|
assert.NoError(t, err) |
|
|
|
|
|
|
|
assert.EqualValues(t, repo.NumClosedMilestones, count) |
|
|
|
} |
|
|
|
} |
|
|
|
test(1) |
|
|
|
test(1) |
|
|
|
test(2) |
|
|
|
test(2) |
|
|
|
test(3) |
|
|
|
test(3) |
|
|
|
assert.EqualValues(t, 0, countRepoMilestones(x, NonexistentID)) |
|
|
|
|
|
|
|
|
|
|
|
count, err := CountRepoClosedMilestones(NonexistentID) |
|
|
|
|
|
|
|
assert.NoError(t, err) |
|
|
|
|
|
|
|
assert.EqualValues(t, 0, count) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestMilestoneStats(t *testing.T) { |
|
|
|
func TestMilestoneStats(t *testing.T) { |
|
|
|
assert.NoError(t, PrepareTestDatabase()) |
|
|
|
assert.NoError(t, PrepareTestDatabase()) |
|
|
|
test := func(repoID int64) { |
|
|
|
test := func(repoID int64) { |
|
|
|
repo := AssertExistsAndLoadBean(t, &Repository{ID: repoID}).(*Repository) |
|
|
|
repo := AssertExistsAndLoadBean(t, &Repository{ID: repoID}).(*Repository) |
|
|
|
open, closed := MilestoneStats(repoID) |
|
|
|
open, closed, err := MilestoneStats(repoID) |
|
|
|
|
|
|
|
assert.NoError(t, err) |
|
|
|
assert.EqualValues(t, repo.NumMilestones-repo.NumClosedMilestones, open) |
|
|
|
assert.EqualValues(t, repo.NumMilestones-repo.NumClosedMilestones, open) |
|
|
|
assert.EqualValues(t, repo.NumClosedMilestones, closed) |
|
|
|
assert.EqualValues(t, repo.NumClosedMilestones, closed) |
|
|
|
} |
|
|
|
} |
|
|
@ -178,7 +189,8 @@ func TestMilestoneStats(t *testing.T) { |
|
|
|
test(2) |
|
|
|
test(2) |
|
|
|
test(3) |
|
|
|
test(3) |
|
|
|
|
|
|
|
|
|
|
|
open, closed := MilestoneStats(NonexistentID) |
|
|
|
open, closed, err := MilestoneStats(NonexistentID) |
|
|
|
|
|
|
|
assert.NoError(t, err) |
|
|
|
assert.EqualValues(t, 0, open) |
|
|
|
assert.EqualValues(t, 0, open) |
|
|
|
assert.EqualValues(t, 0, closed) |
|
|
|
assert.EqualValues(t, 0, closed) |
|
|
|
} |
|
|
|
} |
|
|
|