From 31b239fba26010680dc1810737ef8ef3fda2fd18 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 14 Jan 2014 08:27:34 -0800 Subject: [PATCH] provisioners/docker: unit tests for config /cc @fgrehm - I'm starting to unit test more and more of the plugins. Just showing you an example because it is quite easy. :) --- .../provisioners/docker/config_test.rb | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 test/unit/plugins/provisioners/docker/config_test.rb diff --git a/test/unit/plugins/provisioners/docker/config_test.rb b/test/unit/plugins/provisioners/docker/config_test.rb new file mode 100644 index 000000000..5ae35fa2b --- /dev/null +++ b/test/unit/plugins/provisioners/docker/config_test.rb @@ -0,0 +1,44 @@ +require File.expand_path("../../../../base", __FILE__) + +require Vagrant.source_root.join("plugins/provisioners/docker/config") + +describe VagrantPlugins::Docker::Config do + subject { described_class.new } + + describe "#images" do + it "stores them in a set" do + subject.images = ["1", "1", "2"] + subject.finalize! + expect(subject.images.to_a.sort).to eql(["1", "2"]) + end + + it "overrides previously set images" do + subject.images = ["3"] + subject.images = ["1", "1", "2"] + subject.finalize! + expect(subject.images.to_a.sort).to eql(["1", "2"]) + end + end + + describe "#pull_images" do + it "adds images to the list of images to build" do + subject.pull_images("1") + subject.pull_images("2", "3") + subject.finalize! + expect(subject.images.to_a.sort).to eql(["1", "2", "3"]) + end + end + + describe "#version" do + it "defaults to latest" do + subject.finalize! + expect(subject.version).to eql(:latest) + end + + it "converts to a symbol" do + subject.version = "v27" + subject.finalize! + expect(subject.version).to eql(:v27) + end + end +end