Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software:2222/vole.git

A free and open-source forge that lives in your Git repo.

Code

395 commit(s) on main

update readme Keenan Nemetz · 38m ago 32290114
history blame raw 1.7 KiB
1package web
2
3import (
4 "testing"
5 "time"
6)
7
8func TestContributorStatsOmitZeroCounts(t *testing.T) {
9 view := contributorView{Merged: 1, Fixed: 2, Reviews: 1}
10 got := view.Stats()
11 if len(got) != 3 {
12 t.Fatalf("Stats() = %+v, want three non-zero counts", got)
13 }
14 if got[0].Icon != "git-merge" || got[0].Count != 1 || got[0].Label != "1 change merged" {
15 t.Fatalf("first stat = %+v", got[0])
16 }
17 if got[1].Icon != "circle-check" || got[1].Label != "2 issues fixed" {
18 t.Fatalf("second stat = %+v", got[1])
19 }
20 if got[2].Icon != "check" || got[2].Label != "1 review" {
21 t.Fatalf("third stat = %+v", got[2])
22 }
23 if len((contributorView{}).Stats()) != 0 {
24 t.Fatal("an account with no counts still renders a mark")
25 }
26}
27
28func TestNewestOverviewSortsAndLimits(t *testing.T) {
29 base := time.Date(2026, 10, 22, 12, 0, 0, 0, time.UTC)
30 list := []overviewEntity{
31 {ID: "b", Created: base},
32 {ID: "newest", Created: base.Add(2 * time.Hour)},
33 {ID: "c", Created: base.Add(-time.Hour)},
34 {ID: "a", Created: base},
35 {ID: "oldest", Created: base.Add(-2 * time.Hour)},
36 {ID: "d", Created: base.Add(-3 * time.Hour)},
37 {ID: "e", Created: base.Add(-4 * time.Hour)},
38 }
39 got := newestOverview(list)
40 if len(got) != overviewSideLimit {
41 t.Fatalf("newestOverview returned %d rows, want %d", len(got), overviewSideLimit)
42 }
43 if got[0].ID != "newest" {
44 t.Fatalf("first row = %q, want newest", got[0].ID)
45 }
46 // Equal timestamps are ordered by id, not by the order the rows arrived in.
47 if got[1].ID != "b" || got[2].ID != "a" {
48 t.Fatalf("tied rows = %q, %q; want b then a", got[1].ID, got[2].ID)
49 }
50 if got[len(got)-1].ID != "oldest" {
51 t.Fatalf("last row = %q, want oldest after the limit", got[len(got)-1].ID)
52 }
53}
54