From 2de0d7e79cb5b751c09937aeaacc882cf294e0f7 Mon Sep 17 00:00:00 2001 From: Pavel Rusin Date: Mon, 5 Jul 2021 17:33:07 +0300 Subject: [PATCH] Hyperv: add tests for --force flag support for stop VM --- .../hyperv/action/halt_instance_test.rb | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/unit/plugins/providers/hyperv/action/halt_instance_test.rb diff --git a/test/unit/plugins/providers/hyperv/action/halt_instance_test.rb b/test/unit/plugins/providers/hyperv/action/halt_instance_test.rb new file mode 100644 index 000000000..b6f79f339 --- /dev/null +++ b/test/unit/plugins/providers/hyperv/action/halt_instance_test.rb @@ -0,0 +1,29 @@ +require_relative "../../../../base" + +require Vagrant.source_root.join("plugins/providers/hyperv/action/halt_instance") + +describe VagrantPlugins::HyperV::Action::HaltInstance do + let(:app){ double("app") } + let(:env){ {ui: ui, machine: machine} } + let(:ui){ double("ui") } + let(:provider){ double("provider", driver: driver) } + let(:driver){ double("driver") } + let(:machine){ double("machine", provider: provider, data_dir: "/dev/null") } + let(:subject){ described_class.new(app, env) } + + before do + allow(app).to receive(:call) + allow(ui).to receive(:info) + allow(driver).to receive(:halt) + end + + it "should call the app on success" do + expect(app).to receive(:call) + subject.call(env) + end + + it "should call the driver to halt the vm" do + expect(driver).to receive(:halt) + subject.call(env) + end +end