25 lines
686 B
Go
25 lines
686 B
Go
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)
|
|
}
|
|
}
|
|
}
|