Boolean types (and possibly a few others) are returned as wrapper
classes when coming out from proto mapping; these need to be unwrapped
otherwise the caller who is expecting a nice clean boolean value ends up
with an icky protobuf class.
This fixes the shell provisioner, which relies on a communicator
receiving a settings hash `{error_check: false}` for a command that
usually fails but it sent just in case before provisioning starts.
40 lines
1.0 KiB
Ruby
40 lines
1.0 KiB
Ruby
require File.expand_path("../../../base", __dir__)
|
|
|
|
require Vagrant.source_root.join("plugins/commands/serve/command")
|
|
|
|
describe VagrantPlugins::CommandServe::Mappers do
|
|
include_context "unit"
|
|
|
|
subject { described_class.new }
|
|
|
|
context "Hash" do
|
|
it "unwraps wrapper types when they show up in the Hash" do
|
|
input = Hashicorp::Vagrant::Sdk::Args::Hash.new(
|
|
fields: {
|
|
"error_check" => Google::Protobuf::Any.pack(
|
|
Google::Protobuf::BoolValue.new(value: false)
|
|
)
|
|
}
|
|
)
|
|
output = subject.map(input, to: Hash)
|
|
|
|
expect(output).to eq({error_check: false})
|
|
end
|
|
end
|
|
|
|
context "Array" do
|
|
it "unwraps wrapper types when they show up in the Array" do
|
|
input = Hashicorp::Vagrant::Sdk::Args::Array.new(
|
|
list: [
|
|
Google::Protobuf::Any.pack(
|
|
Google::Protobuf::BoolValue.new(value: false)
|
|
),
|
|
],
|
|
)
|
|
output = subject.map(input, to: Array)
|
|
|
|
expect(output).to eq([false])
|
|
end
|
|
end
|
|
end
|