func RegisterHooks(hs hook.HookSet, runner Runner, config process.Env, configurer network.Configurer) { hs.Register(hook.PARENT_BEFORE_CLONE, func() { must(runner.Run(exec.Command("./hook-parent-before-clone.sh"))) }) hs.Register(hook.PARENT_AFTER_CLONE, func() { must(runner.Run(exec.Command("./hook-parent-after-clone.sh"))) must(configureHostNetwork(config, configurer)) }) }
. "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("HookSet", func() { var registry hook.HookSet BeforeEach(func() { registry = make(hook.HookSet) }) Context("when the first argument names a registered hook", func() { It("runs the hook", func() { wasRun := false registry.Register("a-hook", func() { wasRun = true }) registry.Main("a-hook") Expect(wasRun).To(BeTrue()) }) }) Context("when the first argument does not name a registered hook", func() { It("panics", func() { Expect(func() { registry.Main("does-not-hook") }).To(Panic()) }) }) Context("when multiple hooks are registered with the same name", func() { It("panics", func() {