For option arguments that must be members of an array, do the check in the option parsing by providing an array of allowed option arguments (e.g. vm create -s bad). Emit better errors for options arguments that should be integers (e.g. fw add-rule -s/-e), and for regular arguments that should be integers (e.g. lb create src-port/dst-port). Include help output in additional cases: * invalid id formats with slashes * invalid/duplicate/missing fields used when multiple fields separated by a comma is allowed * invalid object references when using post subcommands * invalid location for list -l option
20 lines
843 B
Ruby
20 lines
843 B
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative "../spec_helper"
|
|
|
|
RSpec.describe Clover, "cli pg delete-firewall-rule" do
|
|
before do
|
|
expect(Config).to receive(:postgres_service_project_id).and_return(@project.id).at_least(:once)
|
|
end
|
|
|
|
it "deletes the specified firewall rule for the database" do
|
|
cli(%w[pg eu-central-h1/test-pg create -s standard-2 -S 64])
|
|
pg = PostgresResource.first
|
|
fwr = pg.firewall_rules_dataset.first
|
|
expect(cli(%w[pg eu-central-h1/test-pg delete-firewall-rule a/b], status: 400)).to start_with "! Invalid firewall rule id format\n"
|
|
expect(pg.firewall_rules_dataset).not_to be_empty
|
|
expect(cli(%W[pg eu-central-h1/test-pg delete-firewall-rule #{fwr.ubid}])).to eq "Firewall rule, if it exists, has been scheduled for deletion\n"
|
|
expect(pg.firewall_rules_dataset).to be_empty
|
|
end
|
|
end
|