Exemple #1
0
func (p *provider) ProvideFilter(containerId string) network.Filter {
	return network.NewFilter(iptables.NewLoggingChain(p.chainPrefix+containerId, p.useKernelLogging, p.runner, p.log.Session(containerId).Session("filter")))
}
	"github.com/cloudfoundry-incubator/garden"
	"github.com/cloudfoundry-incubator/garden-linux/network"
	"github.com/cloudfoundry-incubator/garden-linux/network/iptables/fakes"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Filter", func() {
	var (
		fakeChain *fakes.FakeChain
		filter    network.Filter
	)

	BeforeEach(func() {
		fakeChain = new(fakes.FakeChain)
		filter = network.NewFilter(fakeChain)
		Expect(filter).ToNot(BeNil())
	})

	Context("Setup", func() {
		It("sets up the chain", func() {
			Expect(filter.Setup("logPrefix")).To(Succeed())
			Expect(fakeChain.SetupCallCount()).To(Equal(1))
			Expect(fakeChain.SetupArgsForCall(0)).To(Equal("logPrefix"))
		})

		Context("when chain setup returns an error", func() {
			It("Setup wraps the error and returns it", func() {
				fakeChain.SetupReturns(errors.New("x"))
				err := filter.Setup("logPrefix")
				Expect(err).To(MatchError("network: log chain setup: x"))