createBridge = commands.CreateBridge{ Name: "my-bridge", } }) It("creates a bridge device", func() { err := createBridge.Execute(context) Expect(err).NotTo(HaveOccurred()) Expect(linkFactory.CreateBridgeCallCount()).To(Equal(1)) Expect(linkFactory.CreateBridgeArgsForCall(0)).To(Equal("my-bridge")) }) Context("when creating the bridge fails", func() { BeforeEach(func() { linkFactory.CreateBridgeReturns(errors.New("no bridge for sale")) }) It("wraps and propagates the error", func() { err := createBridge.Execute(context) Expect(err).To(MatchError("create bridge: no bridge for sale")) }) }) Describe("String", func() { It("is self describing", func() { Expect(createBridge.String()).To(Equal("ip link add dev my-bridge type bridge")) }) }) })