package web import ( "testing" "git.zio.sh/cs2/simpleadmin-web/internal/live" "git.zio.sh/cs2/simpleadmin-web/internal/store" ) func TestIsClanID(t *testing.T) { for _, c := range []struct { id uint64 want bool }{ {103582791429521412, true}, // a group {103582791429521408, false}, // account 0 {76561198012345678, false}, // a player {0, false}, } { if got := isClanID(c.id); got != c.want { t.Errorf("isClanID(%d) = %v, want %v", c.id, got, c.want) } } } func TestVerifyShown(t *testing.T) { on := store.VerifySettings{Enabled: true, GroupID: "103582791429521412"} for _, c := range []struct { info verifyInfo want bool }{ {verifyInfo{Tables: true, Settings: on, Plugin: live.PluginLoaded}, true}, {verifyInfo{Tables: true, Settings: on, Plugin: live.PluginUnknown}, true}, {verifyInfo{Tables: true, Settings: on, Plugin: live.PluginMissing}, false}, {verifyInfo{Tables: false, Settings: on, Plugin: live.PluginLoaded}, false}, {verifyInfo{Tables: true, Settings: store.VerifySettings{Enabled: false, GroupID: on.GroupID}, Plugin: live.PluginLoaded}, false}, {verifyInfo{Tables: true, Settings: store.VerifySettings{Enabled: true}, Plugin: live.PluginLoaded}, false}, } { if got := c.info.Shown(); got != c.want { t.Errorf("%+v: Shown() = %v, want %v", c.info, got, c.want) } } }