Packages: map[string]bias.Blob{ "fake-package-name": bias.Blob{ Name: "fake-package-name", Version: "fake-package-fingerprint-cpi", SHA1: "fake-compiled-package-sha1-cpi", BlobstoreID: "fake-compiled-package-blob-id-cpi", }, }, RenderedTemplatesArchive: bias.RenderedTemplatesArchiveSpec{}, ConfigurationHash: "", } //TODO: use a real state builder mockStateBuilderFactory.EXPECT().NewBuilder(mockBlobstore, mockAgentClient).Return(mockStateBuilder).AnyTimes() mockStateBuilder.EXPECT().Build(jobName, jobIndex, gomock.Any(), gomock.Any()).Return(mockState, nil).AnyTimes() mockState.EXPECT().ToApplySpec().Return(applySpec).AnyTimes() } var newDeployCmd = func() Cmd { deploymentParser := bideplmanifest.NewParser(fs, logger) releaseSetValidator := birelsetmanifest.NewValidator(logger) releaseSetParser := birelsetmanifest.NewParser(fs, logger, releaseSetValidator) fakeRegistryUUIDGenerator = fakeuuid.NewFakeGenerator() fakeRegistryUUIDGenerator.GeneratedUUID = "registry-password" installationValidator := biinstallmanifest.NewValidator(logger) installationParser := biinstallmanifest.NewParser(fs, fakeRegistryUUIDGenerator, logger, installationValidator) deploymentValidator := bideplmanifest.NewValidator(logger) instanceFactory := biinstance.NewFactory(mockStateBuilderFactory)
Update: bideplmanifest.Update{ UpdateWatchTime: bideplmanifest.WatchTime{ Start: 0, End: 5478, }, }, } // apply spec is just returned from instance.State.ToApplySpec() and passed to agentClient.Apply() applySpec = bias.ApplySpec{ Deployment: "fake-deployment-name", } }) JustBeforeEach(func() { expectStateBuild = mockStateBuilder.EXPECT().Build(jobName, jobIndex, deploymentManifest, fakeStage).Return(mockState, nil).AnyTimes() mockState.EXPECT().ToApplySpec().Return(applySpec).AnyTimes() }) It("builds a new instance state", func() { expectStateBuild.Times(1) err := instance.UpdateJobs(deploymentManifest, fakeStage) Expect(err).ToNot(HaveOccurred()) }) It("tells agent to stop jobs, apply a new spec (with new rendered jobs templates), and start jobs", func() { err := instance.UpdateJobs(deploymentManifest, fakeStage) Expect(err).NotTo(HaveOccurred()) Expect(fakeVM.StopCalled).To(Equal(1))
}) JustBeforeEach(func() { jobName := "fake-job-name" jobIndex := 0 // since we're just passing this from State.ToApplySpec() to VM.Apply(), it doesn't need to be filled out applySpec = bias.ApplySpec{ Deployment: "fake-deployment-name", } fakeAgentState := agentclient.AgentState{} fakeVM.GetStateResult = fakeAgentState mockStateBuilderFactory.EXPECT().NewBuilder(mockBlobstore, mockAgentClient).Return(mockStateBuilder).AnyTimes() mockStateBuilder.EXPECT().Build(jobName, jobIndex, deploymentManifest, fakeStage, fakeAgentState).Return(mockState, nil).AnyTimes() mockStateBuilder.EXPECT().BuildInitialState(jobName, jobIndex, deploymentManifest).Return(mockState, nil).AnyTimes() mockState.EXPECT().ToApplySpec().Return(applySpec).AnyTimes() }) Context("when a previous instance exists", func() { var fakeExistingVM *fakebivm.FakeVM BeforeEach(func() { fakeExistingVM = fakebivm.NewFakeVM("existing-vm-cid") fakeVMManager.SetFindCurrentBehavior(fakeExistingVM, true, nil) fakeExistingVM.AgentClientReturn = mockAgentClient }) It("deletes existing vm", func() { _, err := deployer.Deploy(cloud, deploymentManifest, cloudStemcell, registryConfig, fakeVMManager, mockBlobstore, fakeStage)