This allows the server to take appropriate action based on client version. It we add new features that require an updated client version, we can check the client's version, and give them a give the clients a nice error message instructing them to upgrade. This required a minor change to Rodish to execute code after option parsing and before subcommand processing, even if there are no valid subcommands provided. I made that change and released a new version, so this bumps the rodish version. The cli version is stored in cli/version.txt. bin/ubi reads this file when run. In the rake ubi/ubi-cross tasks, the Rakefile reads this file and sets the version in the compiled go file.
25 lines
886 B
Ruby
25 lines
886 B
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative "spec_helper"
|
|
|
|
RSpec.describe Clover, "cli" do
|
|
it "errors if argv is not an array of strings" do
|
|
expect(cli([1], status: 400)).to eq "! Invalid request: No or invalid argv parameter provided\n"
|
|
expect(cli("--version", status: 400)).to eq "! Invalid request: No or invalid argv parameter provided\n"
|
|
end
|
|
|
|
it "errors if token is not provided" do
|
|
header "Authorization", "Foo"
|
|
expect(cli(%w[--version], status: 400)).to eq "! Invalid request: No valid personal access token provided\n"
|
|
end
|
|
|
|
it "handles --version with a valid version" do
|
|
expect(cli(%w[--version])).to match(/\A\d+\.\d+\.\d+\n\z/)
|
|
end
|
|
|
|
it "handles --version with an invalid version" do
|
|
expect(cli(%w[--version], env: {"HTTP_X_UBI_VERSION" => "bad"})).to eq "unknown\n"
|
|
expect(cli(%w[--version], env: {})).to eq "unknown\n"
|
|
end
|
|
end
|