aboutsummaryrefslogtreecommitdiff
path: root/internal/game/admin_owner_test.go
blob: e5926600ede279e0945fc1a0909e63cfd27adb37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package game

import "testing"

func TestRunAdminOnOwnerRejectsShutdown(t *testing.T) {
	g := &Game{owner: newOwner()}
	defer g.stopOwner()
	if !g.RunAdminOnOwner(func() {}) {
		t.Fatal("running owner rejected task")
	}
	g.setShuttingDown()
	if g.RunAdminOnOwner(func() { t.Error("task ran during shutdown") }) {
		t.Error("shutdown accepted task")
	}
	g.stopOwner()
	if g.RunAdminOnOwner(func() { t.Error("task ran after owner stopped") }) {
		t.Error("stopped owner accepted task")
	}
}

func TestRunAdminOnOwnerNeverFallsBackInline(t *testing.T) {
	g := &Game{owner: newOwner()}
	g.stopOwner()
	if g.RunAdminOnOwner(func() { t.Error("task ran inline after stop") }) {
		t.Error("stopped owner accepted task")
	}
}