communicators/winrm: Config unit tests (a little)

This commit is contained in:
Mitchell Hashimoto 2014-03-10 22:54:02 -07:00
parent 2a8a04ebb9
commit eebebd8837
2 changed files with 21 additions and 6 deletions

View File

@ -32,12 +32,12 @@ module VagrantPlugins
def validate(machine)
errors = []
errors << "winrm.username cannot be nil." if machine.config.winrm.username.nil?
errors << "winrm.password cannot be nil." if machine.config.winrm.password.nil?
errors << "winrm.port cannot be nil." if machine.config.winrm.port.nil?
errors << "winrm.guest_port cannot be nil." if machine.config.winrm.guest_port.nil?
errors << "winrm.max_tries cannot be nil." if machine.config.winrm.max_tries.nil?
errors << "winrm.timeout cannot be nil." if machine.config.winrm.timeout.nil?
errors << "winrm.username cannot be nil." if @username.nil?
errors << "winrm.password cannot be nil." if @password.nil?
errors << "winrm.port cannot be nil." if @port.nil?
errors << "winrm.guest_port cannot be nil." if @guest_port.nil?
errors << "winrm.max_tries cannot be nil." if @max_tries.nil?
errors << "winrm.timeout cannot be nil." if @timeout.nil?
{ "WinRM" => errors }
end

View File

@ -0,0 +1,15 @@
require File.expand_path("../../../../base", __FILE__)
require Vagrant.source_root.join("plugins/communicators/winrm/config")
describe VagrantPlugins::CommunicatorWinRM::Config do
let(:machine) { double("machine") }
subject { described_class.new }
it "is valid by default" do
subject.finalize!
result = subject.validate(machine)
expect(result["WinRM"]).to be_empty
end
end