Example #1
0
			"network_host_iface":      "hostIfc",
			"network_container_iface": "containerIfc",
			"bridge_iface":            "bridgeName",
		}
		fakeNetworkConfigurer = &networkFakes.FakeConfigurer{}
	})

	Context("After RegisterHooks has been run", func() {
		JustBeforeEach(func() {
			linux_backend.RegisterHooks(hooks, fakeRunner, config, fakeNetworkConfigurer)
		})

		Context("Inside the host", func() {
			Context("before container creation", func() {
				It("runs the hook-parent-before-clone.sh legacy shell script", func() {
					hooks.Main(hook.PARENT_BEFORE_CLONE)
					Expect(fakeRunner).To(HaveExecutedSerially(fake_command_runner.CommandSpec{
						Path: "hook-parent-before-clone.sh",
					}))
				})

				Context("when the legacy shell script fails", func() {
					BeforeEach(func() {
						fakeRunner.WhenRunning(fake_command_runner.CommandSpec{
							Path: "hook-parent-before-clone.sh",
						}, func(*exec.Cmd) error {
							return errors.New("o no")
						})
					})

					It("panics", func() {
Example #2
0
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() {
			registry.Register("a-hook", func() {})
			Expect(func() { registry.Register("a-hook", func() {}) }).To(Panic())
		})