Rank log: inactive ranks (Guardian) count as promotions to and from, demotion when lost; Guardian is staff

This commit is contained in:
Astra 2026-09-29 17:19:53 +01:00
parent 611b79cdba
commit 0af93d1eab
7 changed files with 76 additions and 24 deletions

View file

@ -0,0 +1,25 @@
package web
import "testing"
func TestInactiveKind(t *testing.T) {
guardian := &rankView{Name: "#rank/guardian", Inactive: true}
mod := &rankView{Name: "#rank/mod"}
owner := &rankView{Name: "#rank/owner"}
for _, c := range []struct {
kind string
old, new *rankView
want string
}{
{"demoted", owner, guardian, "promoted"},
{"promoted", guardian, mod, "promoted"},
{"removed", guardian, nil, "demoted"},
{"added", nil, guardian, "added"},
{"demoted", owner, mod, "demoted"},
{"removed", mod, nil, "removed"},
} {
if got := inactiveKind(c.kind, c.old, c.new); got != c.want {
t.Errorf("%v -> %v: got %s, want %s", c.old, c.new, got, c.want)
}
}
}