def test_it_should_get_all_migrations_in_dir(self, repo_mock): repo_mock.return_value = Mock(**{"tags":[Struct(**{"name":"1"}), Struct(**{"name":"3"}), Struct(**{"name":"2.2"})]}) virtuoso_migrate = SimpleVirtuosoMigrate(self.config) migrations = virtuoso_migrate.get_all_migrations() self.assertNotEqual(None, migrations) self.assertEqual(["1", "3", "2.2"], migrations)
def test_it_should_get_the_latest_version_available(self, git_mock): execute_mock = Mock(**{'return_value':'2.2'}) git_mock.return_value = Mock(**{'execute':execute_mock}) virtuoso_migrate = SimpleVirtuosoMigrate(self.config) self.assertEqual('2.2', virtuoso_migrate.latest_version_available()) git_mock.assert_called_with(self.config.get("database_migrations_dir")) execute_mock.assert_called_with(["git", "describe","--abbrev=0","--tags"])
def test_it_should_not_read_files_again_on_subsequent_calls(self, repo_mock): repo_mock.return_value = Mock(**{"tags":[Struct(**{"name":"1"}), Struct(**{"name":"3"}), Struct(**{"name":"2.2"})]}) virtuoso_migrate = SimpleVirtuosoMigrate(self.config) virtuoso_migrate.get_all_migrations() self.assertEqual(1, repo_mock.call_count) #make the second call virtuoso_migrate.get_all_migrations() self.assertEqual(1, repo_mock.call_count)
def test_it_should_use_get_all_migrations_versions_method_to_check_if_migration_version_exists(self, get_all_migrations_mock): virtuoso_migrate = SimpleVirtuosoMigrate(self.config) self.assertTrue(virtuoso_migrate.check_if_version_exists('3')) self.assertEqual(1, get_all_migrations_mock.call_count) self.assertFalse(virtuoso_migrate.check_if_version_exists('4'))