mirror of
https://github.com/ubicloud/ubicloud.git
synced 2025-10-05 22:31:57 +08:00
Before, worst case scenario was an extra database write. Now, it would perform an unnecessary certificate change for postgres resources. It's best to just skip the updates if the name is the same.
24 lines
1.1 KiB
Ruby
24 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative "../spec_helper"
|
|
|
|
RSpec.describe Clover, "cli pg rename" do
|
|
it "renames PostgreSQL database" do
|
|
expect(Config).to receive(:postgres_service_project_id).and_return(@project.id).at_least(:once)
|
|
cli(%w[pg eu-central-h1/test-pg create -s standard-2 -S 64])
|
|
pg = PostgresResource.first
|
|
expect(pg.semaphores_dataset.all).to eq []
|
|
expect(cli(%w[pg eu-central-h1/test-pg rename new-name])).to eq "PostgreSQL database renamed to new-name\n"
|
|
expect(pg.reload.name).to eq "new-name"
|
|
expect(pg.semaphores_dataset.select_order_map(:name)).to eq %w[refresh_certificates refresh_dns_record]
|
|
end
|
|
|
|
it "does not set semaphores if there is no actual rename" do
|
|
expect(Config).to receive(:postgres_service_project_id).and_return(@project.id).at_least(:once)
|
|
cli(%w[pg eu-central-h1/test-pg create -s standard-2 -S 64])
|
|
pg = PostgresResource.first
|
|
expect(cli(%w[pg eu-central-h1/test-pg rename test-pg])).to eq "PostgreSQL database renamed to test-pg\n"
|
|
expect(pg.reload.name).to eq "test-pg"
|
|
expect(pg.semaphores_dataset.all).to eq []
|
|
end
|
|
end
|