package reloader_test

import (
	"errors"

	"github.com/cloudfoundry-incubator/ducati-daemon/fakes"
	"github.com/cloudfoundry-incubator/ducati-daemon/reloader"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Reloader", func() {
	var (
		monitorReloader *reloader.Reloader
		watcher         *fakes.MissWatcher
		ns              *fakes.Namespace
	)

	BeforeEach(func() {
		watcher = &fakes.MissWatcher{}
		monitorReloader = &reloader.Reloader{
			Watcher: watcher,
		}
		ns = &fakes.Namespace{}

		ns.NameReturns("/some/sbox/path/vni-some-sandbox")
	})

	Describe("Callback", func() {
		It("restart the monitor for the given namespace", func() {
import (
	"errors"
	"os"

	"github.com/cloudfoundry-incubator/ducati-daemon/fakes"
	"github.com/cloudfoundry-incubator/ducati-daemon/sandbox"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/pivotal-golang/lager/lagertest"
)

var _ = Describe("Sandbox", func() {
	var (
		sb          sandbox.Sandbox
		logger      *lagertest.TestLogger
		sbNamespace *fakes.Namespace
		invoker     *fakes.Invoker
		watcher     *fakes.MissWatcher
		linkFactory *fakes.LinkFactory
	)

	BeforeEach(func() {
		logger = lagertest.NewTestLogger("test")
		invoker = &fakes.Invoker{}
		watcher = &fakes.MissWatcher{}
		linkFactory = &fakes.LinkFactory{}
		sbNamespace = &fakes.Namespace{}
		sbNamespace.ExecuteStub = func(callback func(*os.File) error) error {
			return callback(nil)
		}

		sb = sandbox.New(logger, sbNamespace, invoker, linkFactory, watcher)
import (
	"errors"
	"os"

	"github.com/cloudfoundry-incubator/ducati-daemon/executor/commands"
	"github.com/cloudfoundry-incubator/ducati-daemon/fakes"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("StartMonitor", func() {
	var (
		context           *fakes.Context
		sandboxRepository *fakes.Repository
		startMonitor      commands.StartMonitor
		fakeWatcher       *fakes.MissWatcher
		hostNS            *fakes.Namespace

		sandboxNS *fakes.Namespace
	)

	BeforeEach(func() {
		context = &fakes.Context{}
		sandboxRepository = &fakes.Repository{}
		context.SandboxNamespaceRepositoryReturns(sandboxRepository)

		sandboxNS = &fakes.Namespace{}
		sandboxRepository.GetReturns(sandboxNS, nil)

		hostNS = &fakes.Namespace{}
	"errors"
	"os"
	"syscall"

	"github.com/cloudfoundry-incubator/ducati-daemon/fakes"
	"github.com/cloudfoundry-incubator/ducati-daemon/watcher"
	"github.com/tedsuo/ifrit"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("NamespaceWatcher", func() {
	var (
		nsWatcher   *watcher.NamespaceWatcher
		missWatcher *fakes.MissWatcher
		ns          *fakes.Namespace
		process     ifrit.Process
	)

	BeforeEach(func() {
		missWatcher = &fakes.MissWatcher{}
		ns = &fakes.Namespace{}
		nsWatcher = &watcher.NamespaceWatcher{
			MissWatcher: missWatcher,
			Namespace:   ns,
			DeviceName:  "some-vxlan-name",
		}
	})

	JustBeforeEach(func() {
		process = ifrit.Invoke(nsWatcher)