Add basic unit test
This commit is contained in:
parent
7cccddc009
commit
bb2f3b35b9
|
@ -97,6 +97,8 @@ module VagrantPlugins
|
|||
|
||||
# Validate Trigger settings
|
||||
def validate(machine)
|
||||
errors = _detected_errors
|
||||
|
||||
if !@run.nil?
|
||||
# validate proper keys
|
||||
# WARN if invalid keys are used?
|
||||
|
@ -106,6 +108,8 @@ module VagrantPlugins
|
|||
# validate proper keys
|
||||
# WARN if invalid keys are used?
|
||||
end
|
||||
|
||||
{"triggers" => errors}
|
||||
end
|
||||
|
||||
# The String representation of this Trigger.
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
require File.expand_path("../../../../base", __FILE__)
|
||||
|
||||
require Vagrant.source_root.join("plugins/kernel_v2/config/trigger")
|
||||
|
||||
describe VagrantPlugins::Kernel_V2::TriggerConfig do
|
||||
include_context "unit"
|
||||
|
||||
subject { described_class.new }
|
||||
|
||||
let(:machine) { double("machine") }
|
||||
|
||||
def assert_invalid
|
||||
errors = subject.validate(machine)
|
||||
if !errors.values.any? { |v| !v.empty? }
|
||||
raise "No errors: #{errors.inspect}"
|
||||
end
|
||||
end
|
||||
|
||||
def assert_valid
|
||||
errors = subject.validate(machine)
|
||||
if !errors.values.all? { |v| v.empty? }
|
||||
raise "Errors: #{errors.inspect}"
|
||||
end
|
||||
end
|
||||
|
||||
before do
|
||||
env = double("env")
|
||||
allow(env).to receive(:root_path).and_return(nil)
|
||||
allow(machine).to receive(:env).and_return(env)
|
||||
allow(machine).to receive(:provider_config).and_return(nil)
|
||||
allow(machine).to receive(:provider_options).and_return({})
|
||||
|
||||
subject.name = "foo"
|
||||
end
|
||||
|
||||
it "is valid with test defaults" do
|
||||
subject.finalize!
|
||||
assert_valid
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue