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

	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() {
			fakeDB.VersionReturns(nil, errors.New("kablamo"))
		})

		It("fails early", func() {
			var err error
			Eventually(migrationProcess.Wait()).Should(Receive(&err))
			Expect(err).To(MatchError("kablamo"))
			Expect(migrationProcess.Ready()).ToNot(BeClosed())
			Expect(migrationsDone).NotTo(BeClosed())
		})
コード例 #2
0
ファイル: manager_test.go プロジェクト: timani/bbs
					_, version := fakeETCDDB.SetVersionArgsForCall(0)
					Expect(version).To(Equal(&models.Version{CurrentVersion: 99, TargetVersion: 102}))

					_, version = fakeETCDDB.SetVersionArgsForCall(1)
					// Current Version set to last ETCD migration plus 1
					Expect(version).To(Equal(&models.Version{CurrentVersion: 101, TargetVersion: 102}))

					Expect(fakeSQLDB.SetVersionCallCount()).To(Equal(2))
					_, version = fakeSQLDB.SetVersionArgsForCall(0)
					Expect(version).To(Equal(&models.Version{CurrentVersion: 99, TargetVersion: 102}))

					_, version = fakeSQLDB.SetVersionArgsForCall(1)
					Expect(version).To(Equal(&models.Version{CurrentVersion: 102, TargetVersion: 102}))

					Expect(fakeMigration.UpCallCount()).To(Equal(1))
					Expect(fakeMigrationToSQL.UpCallCount()).To(Equal(1))

					Expect(fakeMigration.DownCallCount()).To(Equal(0))
					Expect(fakeMigrationToSQL.DownCallCount()).To(Equal(0))
				})

				It("sets the raw SQL db and the storeClient on the migration to SQL", func() {
					Eventually(migrationProcess.Ready()).Should(BeClosed())
					Expect(migrationsDone).To(BeClosed())
					Expect(fakeMigrationToSQL.SetRawSQLDBCallCount()).To(Equal(1))
					Expect(fakeMigrationToSQL.SetStoreClientCallCount()).To(Equal(1))
				})
			})

			Context("etcd to sql has already been run", func() {