コード例 #1
0
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gbytes"
)

var _ = Describe("NamespaceWriter", func() {
	var (
		nsWriter *executor.NamespaceWriter
		ns       *fakes.Namespace
		writer   *fakes.Writer
		logger   *lagertest.TestLogger
	)

	BeforeEach(func() {
		ns = &fakes.Namespace{}
		ns.MarshalJSONReturns([]byte(`{ "namespace": "my-namespace", "inode": "some-inode" }`), nil)
		ns.ExecuteStub = func(callback func(*os.File) error) error {
			return callback(nil)
		}

		logger = lagertest.NewTestLogger("test")

		writer = &fakes.Writer{}
		nsWriter = &executor.NamespaceWriter{
			Logger:    logger,
			Namespace: ns,
			Writer:    writer,
		}
	})

	It("writes to the wrapped writer in the associated namespace", func() {
コード例 #2
0
		locker        *fakes.Locker
		sub           *fakes.Subscriber
		ns            *fakes.Namespace
		vxlanLinkName string
		resolver      *fakes.Resolver
		missWatcher   watcher.MissWatcher
		arpInserter   *fakes.ARPInserter
	)

	BeforeEach(func() {
		sub = &fakes.Subscriber{}
		logger = lagertest.NewTestLogger("test")
		locker = &fakes.Locker{}

		ns = &fakes.Namespace{}
		ns.MarshalJSONReturns([]byte("{}"), nil)

		vxlanLinkName = "some-vxlan-name"
		resolver = &fakes.Resolver{}

		arpInserter = &fakes.ARPInserter{}
		arpInserter.HandleResolvedNeighborsStub = func(ready chan error, _ namespace.Namespace, _ string, _ <-chan watcher.Neighbor) {
			close(ready)
		}

		missWatcher = watcher.New(logger, sub, locker, resolver, arpInserter)

		ns.ExecuteStub = func(callback func(ns *os.File) error) error {
			err := callback(nil)
			if err != nil {
				return fmt.Errorf("callback failed: %s", err)