mirror of
https://github.com/lukaszraczylo/git-velocity.git
synced 2026-06-05 22:43:56 +00:00
Fix tests.
This commit is contained in:
@@ -383,6 +383,13 @@ func (a *Aggregator) Aggregate(data *models.RawData, dateRange *config.ParsedDat
|
|||||||
if !contains(cm.RepositoriesContributed, issue.Repository) {
|
if !contains(cm.RepositoriesContributed, issue.Repository) {
|
||||||
cm.RepositoriesContributed = append(cm.RepositoriesContributed, issue.Repository)
|
cm.RepositoriesContributed = append(cm.RepositoriesContributed, issue.Repository)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update per-repo contributor metrics
|
||||||
|
rcm := getRepoContributor(issue.Repository, login, cm.Name, cm.AvatarURL)
|
||||||
|
rcm.IssuesOpened++
|
||||||
|
if issue.IsClosed() && issue.ClosedBy != nil && issue.ClosedBy.Login == login {
|
||||||
|
rcm.IssuesClosed++
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate averages and finalize contributor metrics
|
// Calculate averages and finalize contributor metrics
|
||||||
|
|||||||
@@ -646,9 +646,10 @@ func TestCalculator_MultipleRepositories(t *testing.T) {
|
|||||||
// 50 + 30 = 80 commits * 10 = 800
|
// 50 + 30 = 80 commits * 10 = 800
|
||||||
assert.Equal(t, 800, result.Leaderboard[0].Score)
|
assert.Equal(t, 800, result.Leaderboard[0].Score)
|
||||||
|
|
||||||
// Both repos should be tracked
|
// Per-repo scores should reflect repo-specific metrics, not global
|
||||||
|
// Repo1 has 50 commits * 10 = 500
|
||||||
contributor := result.Repositories[0].Contributors[0]
|
contributor := result.Repositories[0].Contributors[0]
|
||||||
assert.Equal(t, 800, contributor.Score.Total)
|
assert.Equal(t, 500, contributor.Score.Total)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCalculator_EmptyMetrics(t *testing.T) {
|
func TestCalculator_EmptyMetrics(t *testing.T) {
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ func TestGenerator_GenerateGlobalJSON(t *testing.T) {
|
|||||||
TotalReviews int `json:"total_reviews"`
|
TotalReviews int `json:"total_reviews"`
|
||||||
TotalLinesAdded int `json:"total_lines_added"`
|
TotalLinesAdded int `json:"total_lines_added"`
|
||||||
TotalLinesDeleted int `json:"total_lines_deleted"`
|
TotalLinesDeleted int `json:"total_lines_deleted"`
|
||||||
GeneratedAt time.Time `json:"GeneratedAt"`
|
GeneratedAt time.Time `json:"generated_at"`
|
||||||
}
|
}
|
||||||
err = json.Unmarshal(data, &result)
|
err = json.Unmarshal(data, &result)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|||||||
Reference in New Issue
Block a user