ubicloud/spec/routes/api/cli/fw/rename_spec.rb
Jeremy Evans b3d8a774b1 Add support for renaming objects to api/sdk/cli
This uses a shared route for all 6 objects, as well as shared
cli and sdk code. Unfortunately, there is not a way to share
such code in openapi.yml, so that part ends up quite verbose.

Eventually, we should add a web interface for this, but it's
best to wait until we refactor the web interfaces for the objects
to consistently use the current postgres web interface.
2025-08-26 02:54:13 +09:00

24 lines
778 B
Ruby

# frozen_string_literal: true
require_relative "../spec_helper"
RSpec.describe Clover, "cli fw rename" do
before do
cli(%w[fw eu-central-h1/test-fw create])
@fw = Firewall.first
end
it "renames object" do
expect(cli(%w[fw eu-central-h1/test-fw rename new-name])).to eq "Firewall renamed to new-name\n"
expect(@fw.reload.name).to eq "new-name"
end
it "handles failure when renaming object" do
expect(cli(%w[fw eu-central-h1/test-fw rename] << "new name", status: 400)).to eq <<~END
! Unexpected response status: 400
Details: Validation failed for following fields: name
name: Name must only contain lowercase letters, numbers, and hyphens and have max length 63.
END
expect(@fw.reload.name).to eq "test-fw"
end
end