Skip to content

Commit

Permalink
feat: add .ps_manager mocks for non-Windows (pwsh_path and pwsh_args)
Browse files Browse the repository at this point in the history
  • Loading branch information
chambersmp committed Apr 15, 2024
1 parent 03ba8c7 commit 56a4b81
Showing 1 changed file with 35 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2110,21 +2110,44 @@
end

describe '.ps_manager' do
before do
allow(Pwsh::Manager).to receive(:powershell_path).and_return('pwsh')
allow(Pwsh::Manager).to receive(:powershell_args).and_return('args')
end
describe '.ps_manager on non-Windows' do
before do
allow(Pwsh::Util).to receive(:on_windows?).and_return(false)
allow(Pwsh::Manager).to receive(:pwsh_path).and_return('pwsh')
allow(Pwsh::Manager).to receive(:pwsh_args).and_return('args')
end

it 'Initializes an instance of the Pwsh::Manager' do
expect(Puppet::Util::Log).to receive(:level).and_return(:normal)
expect(Pwsh::Manager).to receive(:instance).with('pwsh', 'args', debug: false)
expect { provider.ps_manager }.not_to raise_error
it 'Initializes an instance of the Pwsh::Manager' do
expect(Puppet::Util::Log).to receive(:level).and_return(:normal)
expect(Pwsh::Manager).to receive(:instance).with('pwsh', 'args', debug: false)
expect { provider.ps_manager }.not_to raise_error
end

it 'passes debug as true if Puppet::Util::Log.level is debug' do
expect(Puppet::Util::Log).to receive(:level).and_return(:debug)
expect(Pwsh::Manager).to receive(:instance).with('pwsh', 'args', debug: true)
expect { provider.ps_manager }.not_to raise_error
end
end

it 'passes debug as true if Puppet::Util::Log.level is debug' do
expect(Puppet::Util::Log).to receive(:level).and_return(:debug)
expect(Pwsh::Manager).to receive(:instance).with('pwsh', 'args', debug: true)
expect { provider.ps_manager }.not_to raise_error
describe '.ps_manager on Windows' do
before do
allow(Pwsh::Util).to receive(:on_windows?).and_return(true)
allow(Pwsh::Manager).to receive(:powershell_path).and_return('pwsh')
allow(Pwsh::Manager).to receive(:powershell_args).and_return('args')
end

it 'Initializes an instance of the Pwsh::Manager' do
expect(Puppet::Util::Log).to receive(:level).and_return(:normal)
expect(Pwsh::Manager).to receive(:instance).with('pwsh', 'args', debug: false)
expect { provider.ps_manager }.not_to raise_error
end

it 'passes debug as true if Puppet::Util::Log.level is debug' do
expect(Puppet::Util::Log).to receive(:level).and_return(:debug)
expect(Pwsh::Manager).to receive(:instance).with('pwsh', 'args', debug: true)
expect { provider.ps_manager }.not_to raise_error
end
end
end
end

0 comments on commit 56a4b81

Please sign in to comment.