Beta servers: testers can use beta features in servers whose owner opted in
- beta.Configure takes the opted-in servers; testers are looked up in the beta server - beta commands registered per opted-in server and removed when it opts out - beta.ServerEnabled for behaviour that no person triggers - docs updated Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
1 parent
e2fe30b524
commit
fcf4f3ccbd
12 files changed
+491
-122
No files matched your search
@@ -180,3 +180,38 @@ func TestGetBetaSettings(t *testing.T) {
|
||||
t.Fatalf("role = %q, want %q", role, "42")
|
||||
}
|
||||
}
|
||||
|
||||
func TestListBetaGuilds(t *testing.T) {
|
||||
r, _ := testRepo(t)
|
||||
db := r.db
|
||||
ctx := context.Background()
|
||||
if _, err := db.ExecContext(ctx, `CREATE TABLE IF NOT EXISTS beta_guilds (
|
||||
guild_id BIGINT PRIMARY KEY, enabled_by BIGINT NOT NULL, enabled_at TIMESTAMPTZ NOT NULL DEFAULT NOW())`); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
const g = 8800000000000004242
|
||||
_, _ = db.ExecContext(ctx, `DELETE FROM beta_guilds WHERE guild_id = $1`, g)
|
||||
t.Cleanup(func() { _, _ = db.ExecContext(ctx, `DELETE FROM beta_guilds WHERE guild_id = $1`, g) })
|
||||
|
||||
has := func() bool {
|
||||
ids, err := r.ListBetaGuilds(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, id := range ids {
|
||||
if id == "8800000000000004242" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
if has() {
|
||||
t.Fatal("not listed before opting in")
|
||||
}
|
||||
if _, err := db.ExecContext(ctx, `INSERT INTO beta_guilds (guild_id, enabled_by) VALUES ($1, 1)`, g); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !has() {
|
||||
t.Fatal("listed after opting in")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user