From 0be221fbea5a633d4883066f1d8312fe2afb32ae Mon Sep 17 00:00:00 2001 From: Alejandro Ojeda Date: Sun, 18 Sep 2016 03:58:45 +0200 Subject: [PATCH] Add test for provider priority fix This commit adds tests for possible future regressions for the bug fixed in the commit: "Fix Vagrant not prioritizing configured providers correctly". Two very similar tests were added because whether the bug manifests or not depends on the order in which the provider dictionary keys are iterated, which is specific to the dictionary implementation. --- test/unit/vagrant/environment_test.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/unit/vagrant/environment_test.rb b/test/unit/vagrant/environment_test.rb index f2c9cf9bc..15d0a3e0e 100644 --- a/test/unit/vagrant/environment_test.rb +++ b/test/unit/vagrant/environment_test.rb @@ -866,6 +866,30 @@ VF end end + it "is the provider in the Vagrantfile that is usable even if only one specified (1)" do + subject.vagrantfile.config.vm.provider "foo" + subject.vagrantfile.config.vm.finalize! + + plugin_providers[:foo] = [provider_usable_class(true), { priority: 5 }] + plugin_providers[:bar] = [provider_usable_class(true), { priority: 7 }] + + with_temp_env("VAGRANT_DEFAULT_PROVIDER" => nil) do + expect(subject.default_provider).to eq(:foo) + end + end + + it "is the provider in the Vagrantfile that is usable even if only one specified (2)" do + subject.vagrantfile.config.vm.provider "bar" + subject.vagrantfile.config.vm.finalize! + + plugin_providers[:foo] = [provider_usable_class(true), { priority: 7 }] + plugin_providers[:bar] = [provider_usable_class(true), { priority: 5 }] + + with_temp_env("VAGRANT_DEFAULT_PROVIDER" => nil) do + expect(subject.default_provider).to eq(:bar) + end + end + it "is the highest usable provider outside the Vagrantfile" do subject.vagrantfile.config.vm.provider "foo" subject.vagrantfile.config.vm.finalize!