Beispiel #1
0
func TestPushingWithBindingMergedServices(t *testing.T) {
	deps := getPushDependencies()
	deps.appRepo.ReadNotFound = true

	deps.serviceRepo.FindInstanceByNameMap = generic.NewMap(map[interface{}]interface{}{
		"global-service": maker.NewServiceInstance("global-service"),
		"app1-service":   maker.NewServiceInstance("app1-service"),
		"app2-service":   maker.NewServiceInstance("app2-service"),
	})

	deps.manifestRepo.ReadManifestManifest = manifestWithServicesAndEnv()

	ui := callPush(t, []string{}, deps)
	assert.Equal(t, len(deps.binder.AppsToBind), 4)
	assert.Equal(t, deps.binder.AppsToBind[0].Name, "app1")
	assert.Equal(t, deps.binder.AppsToBind[1].Name, "app1")
	assert.Equal(t, deps.binder.InstancesToBindTo[0].Name, "app1-service")
	assert.Equal(t, deps.binder.InstancesToBindTo[1].Name, "global-service")

	assert.Equal(t, deps.binder.AppsToBind[2].Name, "app2")
	assert.Equal(t, deps.binder.AppsToBind[3].Name, "app2")
	assert.Equal(t, deps.binder.InstancesToBindTo[2].Name, "app2-service")
	assert.Equal(t, deps.binder.InstancesToBindTo[3].Name, "global-service")

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Creating", "app1"},
		{"OK"},
		{"Binding service", "app1-service", "app1", "my-org", "my-space", "my-user"},
		{"OK"},
		{"Binding service", "global-service", "app1", "my-org", "my-space", "my-user"},
		{"OK"},
		{"Creating", "app2"},
		{"OK"},
		{"Binding service", "app2-service", "app2", "my-org", "my-space", "my-user"},
		{"OK"},
		{"Binding service", "global-service", "app2", "my-org", "my-space", "my-user"},
		{"OK"},
	})
}
Beispiel #2
0
		})

		It("fails when given the name of an app that is not in the manifest", func() {
			callPush("non-existant-app")
			testassert.SliceContains(ui.Outputs, testassert.Lines{
				{"Failed"},
			})
			Expect(len(appRepo.CreateAppParams)).To(Equal(0))
		})
	})

	It("binds service instances to the app", func() {
		appRepo.ReadNotFound = true

		serviceRepo.FindInstanceByNameMap = generic.NewMap(map[interface{}]interface{}{
			"global-service": maker.NewServiceInstance("global-service"),
			"app1-service":   maker.NewServiceInstance("app1-service"),
			"app2-service":   maker.NewServiceInstance("app2-service"),
		})

		manifestRepo.ReadManifestReturns.Manifest = manifestWithServicesAndEnv()

		callPush()
		Expect(len(binder.AppsToBind)).To(Equal(4))
		Expect(binder.AppsToBind[0].Name).To(Equal("app1"))
		Expect(binder.AppsToBind[1].Name).To(Equal("app1"))
		Expect(binder.InstancesToBindTo[0].Name).To(Equal("app1-service"))
		Expect(binder.InstancesToBindTo[1].Name).To(Equal("global-service"))

		Expect(binder.AppsToBind[2].Name).To(Equal("app2"))
		Expect(binder.AppsToBind[3].Name).To(Equal("app2"))