コード例 #1
0
ファイル: manager_test.go プロジェクト: emc-xchallenge/bbs
	AfterEach(func() {
		ginkgomon.Kill(migrationProcess)
	})

	It("fetches the migration version from the database", func() {
		Eventually(fakeDB.VersionCallCount).Should(Equal(1))
		Consistently(fakeDB.VersionCallCount).Should(Equal(1))

		ginkgomon.Interrupt(migrationProcess)
		Eventually(migrationProcess.Wait()).Should(Receive(BeNil()))
	})

	Context("when there is no version", func() {
		BeforeEach(func() {
			fakeDB.VersionReturns(nil, models.ErrResourceNotFound)
			fakeMigration.VersionReturns(9)
		})

		It("creates a version with the correct target version and does not run any migrations", func() {
			Eventually(fakeDB.SetVersionCallCount).Should(Equal(1))

			_, version := fakeDB.SetVersionArgsForCall(0)
			Expect(version.CurrentVersion).To(BeEquivalentTo(9))
			Expect(version.TargetVersion).To(BeEquivalentTo(9))

			Expect(fakeMigration.UpCallCount()).To(Equal(0))
		})
	})

	Context("when fetching the version fails", func() {
		BeforeEach(func() {
コード例 #2
0
ファイル: manager_test.go プロジェクト: timani/bbs
				Consistently(fakeSQLDB.VersionCallCount).Should(Equal(1))

				Eventually(fakeETCDDB.VersionCallCount).Should(Equal(1))
				Consistently(fakeETCDDB.VersionCallCount).Should(Equal(1))

				ginkgomon.Interrupt(migrationProcess)
				Eventually(migrationProcess.Wait()).Should(Receive(BeNil()))
			})

			// cross-db migration
			Context("but etcd does", func() {
				var fakeMigrationToSQL *migrationfakes.FakeMigration

				BeforeEach(func() {
					fakeMigrationToSQL = &migrationfakes.FakeMigration{}
					fakeMigrationToSQL.VersionReturns(102)
					fakeMigrationToSQL.RequiresSQLReturns(true)

					dbVersion.CurrentVersion = 99
					dbVersion.TargetVersion = 99
					fakeMigration.VersionReturns(100)

					migrations = []migration.Migration{fakeMigrationToSQL, fakeMigration}
				})

				It("sorts all the migrations and runs them", func() {
					Eventually(migrationProcess.Ready()).Should(BeClosed())
					Expect(migrationsDone).To(BeClosed())
					Expect(fakeETCDDB.SetVersionCallCount()).To(Equal(2))

					_, version := fakeETCDDB.SetVersionArgsForCall(0)