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") } }