コード例 #1
0
ファイル: MigrationTest.cs プロジェクト: yousuf8143/Evolve
        public void Run_all_CockroachDB_migrations_work()
        {
            // Arrange
            var cnn    = _dbContainer.CreateDbConnection();
            var evolve = new Evolve(cnn, msg => _output.WriteLine(msg))
            {
                Schemas = new[] { "evolve", "defaultdb" }, // MetadataTableSchema = evolve | migrations = defaultdb
            };

            // Assert
            evolve.AssertInfoIsSuccessfulV2(cnn)
            .ChangeLocations(CockroachDB.MigrationFolder)
            .AssertInfoIsSuccessfulV2(cnn)
            .AssertMigrateIsSuccessfulV2(cnn)
            .AssertInfoIsSuccessfulV2(cnn);

            evolve.ChangeLocations(CockroachDB.ChecksumMismatchFolder)
            .AssertMigrateThrows <EvolveValidationException>(cnn)
            .AssertRepairIsSuccessful(cnn, expectedNbReparation: 1)
            .ChangeLocations(CockroachDB.MigrationFolder)
            .AssertInfoIsSuccessfulV2(cnn);

            evolve.ChangeLocations()
            .AssertEraseThrows <EvolveConfigurationException>(cnn, e => e.IsEraseDisabled = true)
            .AssertEraseIsSuccessful(cnn, e => e.IsEraseDisabled = false)
            .AssertInfoIsSuccessfulV2(cnn);

            evolve.ChangeLocations(CockroachDB.MigrationFolder)
            .AssertMigrateIsSuccessfulV2(cnn)
            .AssertInfoIsSuccessfulV2(cnn);
        }
コード例 #2
0
        public void Run_all_CockroachDB_integration_tests_work()
        {
            // Arrange
            var    cnn        = _dbContainer.CreateDbConnection().AssertIsOpenned();
            var    wcnn       = new WrappedConnection(cnn).AssertDatabaseServerType(DBMS.CockroachDB);
            var    db         = DatabaseHelperFactory.GetDatabaseHelper(DBMS.CockroachDB, wcnn);
            string schemaName = "MyDatabase";
            Schema database   = new CockroachDBDatabase(schemaName, wcnn);

            // Assert
            database.AssertIsNotExists();
            database.AssertCreation();
            database.AssertExists();
            database.AssertIsEmpty();

            db.AssertDefaultSchemaName("defaultdb")
            .AssertMetadataTableCreation(schemaName, "changelog")
            .AssertMetadataTableLockEx()
            .AssertSchemaIsDroppableWhenNewSchemaFound(schemaName) // id:1
            .AssertVersionedMigrationSave()                        // id:2
            .AssertVersionedMigrationChecksumUpdate()
            .AssertRepeatableMigrationSave();                      // id:3

            database.AssertIsNotEmpty();
            database.Erase();
            database.AssertIsEmpty();
            database.Drop();
            database.AssertIsNotExists();

            db.AssertCloseConnection();
        }
コード例 #3
0
        public void Run_all_CockroachDB_migrations_work()
        {
            // Arrange
            string[] locations           = new[] { CockroachDB.MigrationFolder };
            int      expectedNbMigration = Directory.GetFiles(CockroachDB.MigrationFolder).Length;
            var      cnn    = _dbContainer.CreateDbConnection();
            var      evolve = new Evolve(cnn, msg => _output.WriteLine(msg))
            {
                Schemas = new[] { "evolve", "defaultdb" }, // MetadataTableSchema = evolve | migrations = defaultdb
            };

            // Assert
            evolve.AssertMigrateIsSuccessful(cnn, expectedNbMigration, null, locations)
            .AssertMigrateThrows <EvolveValidationException>(cnn, locations: CockroachDB.ChecksumMismatchFolder)
            .AssertRepairIsSuccessful(cnn, expectedNbReparation: 1)
            .AssertMigrateIsSuccessful(cnn, expectedNbMigration: 0)
            .AssertEraseThrows <EvolveConfigurationException>(cnn, e => e.IsEraseDisabled = true)
            .AssertEraseIsSuccessful(cnn, e => e.IsEraseDisabled = false)
            .AssertMigrateIsSuccessful(cnn, expectedNbMigration, locations: CockroachDB.MigrationFolder)
            .AssertInfoIsSuccessful(cnn, expectedNbRows: expectedNbMigration + 2);
        }