Files
ubicloud/spec/routes/api/cli/pg/create_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

42 lines
1.5 KiB
Ruby

# frozen_string_literal: true
require_relative "../spec_helper"
RSpec.describe Clover, "cli pg create" do
before do
expect(Config).to receive(:postgres_service_project_id).and_return(@project.id).at_least(:once)
end
it "creates PostgreSQL database with no options" do
expect(PostgresResource.count).to eq 0
body = cli(%w[pg eu-central-h1/test-pg create])
expect(PostgresResource.count).to eq 1
pg = PostgresResource.first
expect(pg).to be_a PostgresResource
expect(pg.name).to eq "test-pg"
expect(pg.display_location).to eq "eu-central-h1"
expect(pg.target_vm_size).to eq "standard-2"
expect(pg.target_storage_size_gib).to eq 64
expect(pg.ha_type).to eq "none"
expect(pg.version).to eq "16"
expect(pg.flavor).to eq "standard"
expect(body).to eq "PostgreSQL database created with id: #{pg.ubid}\n"
end
it "creates PostgreSQL database with all options" do
expect(PostgresResource.count).to eq 0
body = cli(%w[pg eu-central-h1/test-pg create -s standard-4 -S 128 -h async -v 17 -f lantern])
expect(PostgresResource.count).to eq 1
pg = PostgresResource.first
expect(pg).to be_a PostgresResource
expect(pg.name).to eq "test-pg"
expect(pg.display_location).to eq "eu-central-h1"
expect(pg.target_vm_size).to eq "standard-4"
expect(pg.target_storage_size_gib).to eq 128
expect(pg.ha_type).to eq "async"
expect(pg.version).to eq "17"
expect(pg.flavor).to eq "lantern"
expect(body).to eq "PostgreSQL database created with id: #{pg.ubid}\n"
end
end