func TestHandlerProviderGetReturnsConcreteProvider(t *testing.T) {
	platform := fakeplatform.NewFakePlatform()
	blobstore := fakeblob.NewFakeBlobstore()
	monitor := fakemon.NewFakeMonitor()

	expectedPackageApplier := pa.NewConcretePackageApplier(
		bc.NewFileBundleCollection("/fake-base-dir/data", "/fake-base-dir", "packages", platform.GetFs()),
		blobstore,
		platform.GetCompressor(),
	)

	expectedJobApplier := ja.NewRenderedJobApplier(
		bc.NewFileBundleCollection("/fake-base-dir/data", "/fake-base-dir", "jobs", platform.GetFs()),
		blobstore,
		platform.GetCompressor(),
		monitor,
	)
	dirProvider := boshdirs.NewDirectoriesProvider("/fake-base-dir")
	expectedApplier := NewConcreteApplier(
		expectedJobApplier,
		expectedPackageApplier,
		platform,
		monitor,
		dirProvider,
	)

	provider := NewApplierProvider(platform, blobstore, monitor, dirProvider)
	applier := provider.Get()
	assert.Equal(t, expectedApplier, applier)
}
func buildFactory() (
	deps concreteFactoryDependencies,
	factory Factory) {

	deps.settings = &fakesettings.FakeSettingsService{}
	deps.platform = fakeplatform.NewFakePlatform()
	deps.blobstore = &fakeblobstore.FakeBlobstore{}
	deps.taskService = &faketask.FakeService{}
	deps.notifier = fakenotif.NewFakeNotifier()
	deps.applier = fakeappl.NewFakeApplier()
	deps.compiler = fakecomp.NewFakeCompiler()
	deps.monitor = fakemon.NewFakeMonitor()
	deps.specService = fakeas.NewFakeV1Service()
	deps.dirProvider = boshdirs.NewDirectoriesProvider("/foo")
	deps.drainScriptProvider = boshdrain.NewDrainScriptProvider(nil, nil, deps.dirProvider)

	factory = NewFactory(
		deps.settings,
		deps.platform,
		deps.blobstore,
		deps.taskService,
		deps.notifier,
		deps.applier,
		deps.compiler,
		deps.monitor,
		deps.specService,
		deps.dirProvider,
		deps.drainScriptProvider,
	)
	return
}
Beispiel #3
0
func buildGetStateAction(settings boshsettings.Service) (
	specService *fakeas.FakeV1Service,
	monitor *fakemon.FakeMonitor,
	action getStateAction) {
	monitor = fakemon.NewFakeMonitor()
	specService = fakeas.NewFakeV1Service()
	action = newGetState(settings, specService, monitor)
	return
}
func buildApplier() (
	*fakeja.FakeJobApplier,
	*fakepa.FakePackageApplier,
	*FakeLogRotateDelegate,
	*fakemon.FakeMonitor,
	Applier,
) {
	jobApplier := fakeja.NewFakeJobApplier()
	packageApplier := fakepa.NewFakePackageApplier()
	platform := &FakeLogRotateDelegate{}
	monitor := fakemon.NewFakeMonitor()
	applier := NewConcreteApplier(jobApplier, packageApplier, platform, monitor, boshdirs.NewDirectoriesProvider("/fake-base-dir"))
	return jobApplier, packageApplier, platform, monitor, applier
}
func buildJobApplier() (
	jobsBc *fakebc.FakeBundleCollection,
	blobstore *fakeblob.FakeBlobstore,
	compressor *fakecmd.FakeCompressor,
	monitor *fakemon.FakeMonitor,
	applier JobApplier,
) {
	jobsBc = fakebc.NewFakeBundleCollection()
	blobstore = fakeblob.NewFakeBlobstore()
	compressor = fakecmd.NewFakeCompressor()
	monitor = fakemon.NewFakeMonitor()

	applier = NewRenderedJobApplier(jobsBc, blobstore, compressor, monitor)
	return
}
Beispiel #6
0
func buildStartAction() (monitor *fakemon.FakeMonitor, action startAction) {
	monitor = fakemon.NewFakeMonitor()
	action = newStart(monitor)
	return
}