-
-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add more logging to data migrations
- Loading branch information
Phanindra Srungavarapu
authored and
Phanindra Srungavarapu
committed
Sep 16, 2024
1 parent
7eb80ee
commit 5dc023b
Showing
2 changed files
with
82 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
require 'pact_broker/db/migrate_data' | ||
|
||
RSpec.describe PactBroker::DB::MigrateData do | ||
let(:database_connection) { double('Database Connection') } | ||
let(:options) { {} } | ||
let(:debug) { double('debug', debug: nil) } | ||
|
||
before do | ||
allow(PactBroker::DB::MigrateData).to receive(:logger).and_return(double('logger', debug: debug)) | ||
[ | ||
PactBroker::DB::DataMigrations::SetPacticipantIdsForVerifications, | ||
PactBroker::DB::DataMigrations::SetConsumerIdsForPactPublications, | ||
PactBroker::DB::DataMigrations::SetLatestVersionSequenceValue, | ||
PactBroker::DB::DataMigrations::SetWebhooksEnabled, | ||
PactBroker::DB::DataMigrations::DeleteDeprecatedWebhookExecutions, | ||
PactBroker::DB::DataMigrations::SetCreatedAtForLatestPactPublications, | ||
PactBroker::DB::DataMigrations::SetCreatedAtForLatestVerifications, | ||
PactBroker::DB::DataMigrations::SetExtraColumnsForTags, | ||
PactBroker::DB::DataMigrations::SetPacticipantDisplayName, | ||
PactBroker::DB::DataMigrations::SetWebhookUuid, | ||
PactBroker::DB::DataMigrations::SetConsumerVersionOrderForPactPublications, | ||
PactBroker::DB::DataMigrations::SetInteractionsCounts, | ||
PactBroker::DB::DataMigrations::CreateBranches, | ||
PactBroker::DB::DataMigrations::MigrateIntegrations, | ||
PactBroker::DB::DataMigrations::MigratePactVersionProviderTagSuccessfulVerifications, | ||
PactBroker::DB::DataMigrations::SetContractDataUpdatedAtForIntegrations | ||
].each do |migration| | ||
allow(migration).to receive(:call) | ||
end | ||
end | ||
|
||
describe '.call' do | ||
it 'calls each data migration with the correct database connection' do | ||
described_class.call(database_connection, options) | ||
|
||
[ | ||
PactBroker::DB::DataMigrations::SetPacticipantIdsForVerifications, | ||
PactBroker::DB::DataMigrations::SetConsumerIdsForPactPublications, | ||
PactBroker::DB::DataMigrations::SetLatestVersionSequenceValue, | ||
PactBroker::DB::DataMigrations::SetWebhooksEnabled, | ||
PactBroker::DB::DataMigrations::DeleteDeprecatedWebhookExecutions, | ||
PactBroker::DB::DataMigrations::SetCreatedAtForLatestPactPublications, | ||
PactBroker::DB::DataMigrations::SetCreatedAtForLatestVerifications, | ||
PactBroker::DB::DataMigrations::SetExtraColumnsForTags, | ||
PactBroker::DB::DataMigrations::SetPacticipantDisplayName, | ||
PactBroker::DB::DataMigrations::SetWebhookUuid, | ||
PactBroker::DB::DataMigrations::SetConsumerVersionOrderForPactPublications, | ||
PactBroker::DB::DataMigrations::SetInteractionsCounts, | ||
PactBroker::DB::DataMigrations::CreateBranches, | ||
PactBroker::DB::DataMigrations::MigrateIntegrations, | ||
PactBroker::DB::DataMigrations::MigratePactVersionProviderTagSuccessfulVerifications, | ||
PactBroker::DB::DataMigrations::SetContractDataUpdatedAtForIntegrations | ||
].each do |migration| | ||
expect(migration).to have_received(:call).with(database_connection) | ||
#expect(debug).to have_received(:debug).with("Running data migration #{migration}") | ||
end | ||
end | ||
end | ||
end |