From 1830c81eab2f3327bd0ab5b43f09abbfc6a4a140 Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Thu, 20 Aug 2015 14:15:52 -0700 Subject: [PATCH] Correct and expand docker config tests for commit, discard, export_path --- builder/docker/config_test.go | 36 ++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/builder/docker/config_test.go b/builder/docker/config_test.go index 907222b4f..442c6ffe2 100644 --- a/builder/docker/config_test.go +++ b/builder/docker/config_test.go @@ -52,10 +52,11 @@ func TestConfigPrepare_exportPath(t *testing.T) { raw := testConfig() - // No export path + // No export path. This is invalid. Previously this would not error during + // validation and as a result the failure would happen at build time. delete(raw, "export_path") _, warns, errs := NewConfig(raw) - testConfigOk(t, warns, errs) + testConfigErr(t, warns, errs) // Good export path raw["export_path"] = "good" @@ -70,14 +71,39 @@ func TestConfigPrepare_exportPath(t *testing.T) { func TestConfigPrepare_exportPathAndCommit(t *testing.T) { raw := testConfig() + + // Export but no commit (explicit default) + raw["commit"] = false + _, warns, errs := NewConfig(raw) + testConfigOk(t, warns, errs) + + // Commit AND export specified (invalid) raw["commit"] = true + _, warns, errs = NewConfig(raw) + testConfigErr(t, warns, errs) - // No export path + // Commit but no export + delete(raw, "export_path") + _, warns, errs = NewConfig(raw) + testConfigOk(t, warns, errs) +} + +func TestConfigPrepare_exportDiscard(t *testing.T) { + raw := testConfig() + + // Export but no discard (explicit default) + raw["discard"] = false _, warns, errs := NewConfig(raw) + testConfigOk(t, warns, errs) + + // Discard AND export (invalid) + raw["discard"] = true + _, warns, errs = NewConfig(raw) testConfigErr(t, warns, errs) - // No commit - raw["commit"] = false + // Discard but no export + raw["discard"] = true + delete(raw, "export_path") _, warns, errs = NewConfig(raw) testConfigOk(t, warns, errs) }