From bf7cd4fb0ab6c20a20a883128a2d164f82d5ee7c Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Tue, 12 Jun 2018 12:32:04 -0700 Subject: [PATCH] Add test coverage for powershell module option --- test/unit/vagrant/util/powershell_test.rb | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/unit/vagrant/util/powershell_test.rb b/test/unit/vagrant/util/powershell_test.rb index ce30bd4d1..0733f7783 100644 --- a/test/unit/vagrant/util/powershell_test.rb +++ b/test/unit/vagrant/util/powershell_test.rb @@ -135,6 +135,14 @@ describe Vagrant::Util::PowerShell do end described_class.execute("custom-command", env: {"TEST_KEY" => "test-value"}) end + + it "should define a custom module path" do + expect(Vagrant::Util::Subprocess).to receive(:execute) do |*args| + comm = args.detect{|s| s.to_s.include?("custom-command") } + expect(comm.to_s).to include("$env:PSModulePath+';C:\\My-Path'") + end + described_class.execute("custom-command", module_path: "C:\\My-Path") + end end describe ".execute_cmd" do @@ -183,6 +191,15 @@ describe Vagrant::Util::PowerShell do described_class.execute_cmd("custom-command", env: {"TEST_KEY" => "test-value"}) end + it "should define a custom module path" do + expect(Vagrant::Util::Subprocess).to receive(:execute) do |*args| + comm = args.detect{|s| s.to_s.include?("custom-command") } + expect(comm.to_s).to include("$env:PSModulePath+';C:\\My-Path'") + result + end + described_class.execute_cmd("custom-command", module_path: "C:\\My-Path") + end + context "with command output" do let(:stdout){ "custom-output" } @@ -246,6 +263,15 @@ describe Vagrant::Util::PowerShell do described_class.execute_inline("custom-command", env: {"TEST_KEY" => "test-value"}) end + it "should define a custom module path" do + expect(Vagrant::Util::Subprocess).to receive(:execute) do |*args| + comm = args.detect{|s| s.to_s.include?("custom-command") } + expect(comm.to_s).to include("$env:PSModulePath+';C:\\My-Path'") + result + end + described_class.execute_inline("custom-command", module_path: "C:\\My-Path") + end + it "should return a result instance" do expect(described_class.execute_inline("cmd")).to eq(result) end