Fix MachineState mapper so IsRunning actions work

The IsRunning action checks if `env[:machine].state.id == :running` but
this check was never passing as the protobuf-washed version of machine
state was yielding a machine state w/ a string value like `"running"`.

Easy fix in the mapper!
This commit is contained in:
Paul Hinze 2022-02-10 10:59:51 -06:00
parent a5f0996f5f
commit 8730b9f100
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
2 changed files with 12 additions and 1 deletions

View File

@ -116,7 +116,7 @@ module VagrantPlugins
def converter(m)
Vagrant::MachineState.new(
m.id, m.short_description, m.long_description
m.id.to_sym, m.short_description, m.long_description
)
end
end

View File

@ -36,4 +36,15 @@ describe VagrantPlugins::CommandServe::Mappers do
expect(output).to eq([false])
end
end
context "MachineState" do
it "yields an id that's a symbol, not a string" do
input = Hashicorp::Vagrant::Sdk::Args::Target::Machine::State.new(
id: "running",
)
output = subject.map(input, to: Vagrant::MachineState)
expect(output.id).to eq(:running)
end
end
end