vole
Clone
Read only, no credentials:
https://rodent.software/git/vole.git
Write over SSH with a registered key:
git clone ssh://git@0.0.0.0:2222/vole.git
A free and open-source forge that lives in your Git repo.
Merge change request 01M70WES5ZZDJ6RP226WB11BBZ: Let people rename and remove their own passkeys
keenan · 1h ago
4b8c9e1d
| 1 | package web |
| 2 | |
| 3 | // The change list shows one status per row. These tests pin the words and the |
| 4 | // order that decides which answer wins when several are true at once. |
| 5 | |
| 6 | import ( |
| 7 | "strings" |
| 8 | "testing" |
| 9 | ) |
| 10 | |
| 11 | func TestChangeStatusSaysWhereTheChangeIs(t *testing.T) { |
| 12 | t.Parallel() |
| 13 | cases := []struct { |
| 14 | name string |
| 15 | state string |
| 16 | current int |
| 17 | required int |
| 18 | checks changeChecks |
| 19 | ciHeld string |
| 20 | conflict string |
| 21 | wantKey string |
| 22 | wantLabel string |
| 23 | wantNoteHas string |
| 24 | }{ |
| 25 | { |
| 26 | name: "merged", state: "merged", required: 1, |
| 27 | wantKey: "merged", wantLabel: "Merged", wantNoteHas: "landed", |
| 28 | }, |
| 29 | { |
| 30 | name: "closed", state: "closed", required: 1, |
| 31 | wantKey: "closed", wantLabel: "Closed", wantNoteHas: "without merging", |
| 32 | }, |
| 33 | { |
| 34 | name: "a held contributor tip comes first", state: "open", required: 1, |
| 35 | checks: changeChecks{Pending: true}, ciHeld: "contrib/alice/fix", |
| 36 | wantKey: "waiting", wantLabel: "Waiting on CI approval", |
| 37 | wantNoteHas: "contrib/alice/fix", |
| 38 | }, |
| 39 | { |
| 40 | name: "a failure beats the queue", state: "open", required: 1, |
| 41 | checks: changeChecks{Failed: true, Pending: true}, |
| 42 | wantKey: "failed", wantLabel: "CI failed", |
| 43 | }, |
| 44 | { |
| 45 | name: "running jobs are a wait", state: "open", required: 1, |
| 46 | checks: changeChecks{Pending: true}, |
| 47 | wantKey: "waiting", wantLabel: "Waiting on CI jobs", |
| 48 | }, |
| 49 | { |
| 50 | // A runner that could not start a job is not a verdict about the commit, |
| 51 | // so the list must not read as "CI failed" (see issue #246). |
| 52 | name: "a job that never started is not a failure", state: "open", required: 1, |
| 53 | checks: changeChecks{Broken: true}, |
| 54 | wantKey: "waiting", wantLabel: "CI could not run", |
| 55 | wantNoteHas: "nothing was tested", |
| 56 | }, |
| 57 | { |
| 58 | name: "a real failure still outranks a job that never started", state: "open", required: 1, |
| 59 | checks: changeChecks{Failed: true, Broken: true}, |
| 60 | wantKey: "failed", wantLabel: "CI failed", |
| 61 | }, |
| 62 | { |
| 63 | name: "review after the checks", state: "open", current: 0, required: 2, |
| 64 | wantKey: "review", wantLabel: "Waiting for review", |
| 65 | wantNoteHas: "0 of 2 required approvals", |
| 66 | }, |
| 67 | { |
| 68 | name: "a conflict outranks the approval", state: "open", current: 1, required: 1, |
| 69 | conflict: "main", |
| 70 | wantKey: "conflict", wantLabel: "Merge conflict", wantNoteHas: "main", |
| 71 | }, |
| 72 | { |
| 73 | name: "approved", state: "open", current: 1, required: 1, |
| 74 | wantKey: "ready", wantLabel: "Ready to merge", wantNoteHas: "required approvals are in", |
| 75 | }, |
| 76 | { |
| 77 | name: "no review required", state: "open", required: 0, |
| 78 | wantKey: "ready", wantLabel: "Ready to merge", wantNoteHas: "No approval is required", |
| 79 | }, |
| 80 | } |
| 81 | for _, tc := range cases { |
| 82 | tc := tc |
| 83 | t.Run(tc.name, func(t *testing.T) { |
| 84 | t.Parallel() |
| 85 | got := changeStatusFor(tc.state, "main", tc.current, tc.required, tc.checks, tc.ciHeld, tc.conflict) |
| 86 | if got.Key != tc.wantKey || got.Label != tc.wantLabel { |
| 87 | t.Fatalf("status = %q %q, want %q %q", got.Key, got.Label, tc.wantKey, tc.wantLabel) |
| 88 | } |
| 89 | if got.Icon == "" { |
| 90 | t.Fatal("status has no icon") |
| 91 | } |
| 92 | if tc.wantNoteHas != "" && !strings.Contains(got.Note, tc.wantNoteHas) { |
| 93 | t.Fatalf("note %q does not mention %q", got.Note, tc.wantNoteHas) |
| 94 | } |
| 95 | }) |
| 96 | } |
| 97 | } |
| 98 |