Files
ubicloud/spec/routes/api/cli/pg/reset-superuser-password_spec.rb
Jeremy Evans b4e14bbe25 Ensure cli response bodies end with newline
Currently, response bodies mix trailing newline and no trailing
newline, and it kind of works because bin/ubi is written in Ruby
and uses IO#puts, which will automatically add a newline if the
string being printed does not end with a newline.  However,
other languages may not have similar behavior, and for consistency,
it is best if the server always uses newlines in cli responses.
2025-02-21 09:32:10 -08:00

19 lines
782 B
Ruby

# frozen_string_literal: true
require_relative "../spec_helper"
RSpec.describe Clover, "cli pg reset-superuser-password" do
before do
expect(Config).to receive(:postgres_service_project_id).and_return(@project.id).at_least(:once)
end
it "schedules reset of superuser password for database" do
cli(%w[pg eu-central-h1/test-pg create])
expect(Semaphore.where(name: "update_superuser_password")).to be_empty
pg = PostgresResource.first
expect(cli(%w[pg eu-central-h1/test-pg reset-superuser-password fooBar123456])).to eq "Superuser password reset scheduled for PostgreSQL database with id: #{pg.ubid}\n"
expect(Semaphore.where(name: "update_superuser_password")).not_to be_empty
expect(pg.reload.superuser_password).to eq "fooBar123456"
end
end