oldSpec := exampleSpec()
			newSpec := exampleSpec()

			s := newSpec.PackageSpecs["foo"]
			s.Sha1 = "foo_updated_sha1"
			newSpec.PackageSpecs["foo"] = s

			s = newSpec.PackageSpecs["bar"]
			s.Sha1 = "bar_updated_sha1"
			newSpec.PackageSpecs["bar"] = s

			params = NewUpdateParams(oldSpec, newSpec)
		})

		It("runs drain script", func() {
			runner.AddProcess("/fake/script job_unchanged hash_unchanged bar foo",
				&fakesys.FakeProcess{WaitResult: boshsys.Result{Stdout: "1"}})

			err := script.Run()
			Expect(err).ToNot(HaveOccurred())

			expectedCmd := boshsys.Command{
				Name: "/fake/script",
				Args: []string{"job_unchanged", "hash_unchanged", "bar", "foo"},
				Env: map[string]string{
					"PATH":                "/usr/sbin:/usr/bin:/sbin:/bin",
					"BOSH_JOB_STATE":      "{\"persistent_disk\":42}",
					"BOSH_JOB_NEXT_STATE": "{\"persistent_disk\":42}",
				},
			}

			Expect(len(runner.RunComplexCommands)).To(Equal(1))
	Describe("Run", func() {
		Context("when apply spec is successfully retrieved", func() {
			Context("when current agent has a job spec template", func() {
				BeforeEach(func() {
					currentSpec := boshas.V1ApplySpec{}
					currentSpec.JobSpec.Template = "fake-job-name"
					specService.Spec = currentSpec
				})

				Context("when errand script exits with non-0 exit code (execution of script is ok)", func() {
					BeforeEach(func() {
						cmdRunner.AddProcess("/fake-jobs-dir/fake-job-name/bin/run", &fakesys.FakeProcess{
							WaitResult: boshsys.Result{
								Stdout:     "fake-stdout",
								Stderr:     "fake-stderr",
								ExitStatus: 0,
							},
						})
					})

					It("returns errand result without error after running an errand", func() {
						result, err := action.Run()
						Expect(err).ToNot(HaveOccurred())
						Expect(result).To(Equal(
							ErrandResult{
								Stdout:     "fake-stdout",
								Stderr:     "fake-stderr",
								ExitStatus: 0,
							},
						))
					ExitStatus: 0,
					Sticky:     true,
				})
				certManager = cert.NewUbuntuCertManager(fakeFs, fakeCmdRunner, 1, log)
				fakeResult = boshsys.Result{
					Stdout:     "",
					Stderr:     "",
					ExitStatus: 0,
					Error:      nil,
				}

				fakeProcess1 = &fakesys.FakeProcess{WaitResult: fakeResult}
				fakeProcess2 = &fakesys.FakeProcess{WaitResult: fakeResult}
				fakeProcess3 = &fakesys.FakeProcess{WaitResult: fakeResult}

				fakeCmdRunner.AddProcess("/usr/sbin/update-ca-certificates -f", fakeProcess1)
				fakeCmdRunner.AddProcess("/usr/sbin/update-ca-certificates -f", fakeProcess2)
				fakeCmdRunner.AddProcess("/usr/sbin/update-ca-certificates -f", fakeProcess3)
			})

			SharedLinuxCertManagerExamples("/usr/local/share/ca-certificates", "/usr/sbin/update-ca-certificates")

			It("updates certs", func() {
				err := certManager.UpdateCertificates(cert1)

				Expect(fakeProcess1.Waited).To(BeTrue())
				Expect(fakeProcess1.TerminatedNicely).To(BeFalse())

				Expect(err).ToNot(HaveOccurred())
			})