Added Prepare tests around formula URLs
Signed-off-by: Andrew Cornies <acornies@gmail.com>
This commit is contained in:
parent
a2ea308881
commit
24739270cf
|
@ -363,7 +363,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.C
|
|||
for _, f := range formulas {
|
||||
if _, err := os.Stat(f); !os.IsNotExist(err) && f != p.config.LocalStateTree {
|
||||
ui.Message(fmt.Sprintf("Removing Salt formula: %s", f))
|
||||
os.RemoveAll(f)
|
||||
defer os.RemoveAll(f)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -325,3 +325,33 @@ func TestProvisionerPrepare_GuestOSType(t *testing.T) {
|
|||
t.Fatalf("GuestOSType should be 'windows'")
|
||||
}
|
||||
}
|
||||
|
||||
func TestProvisionerPrepare_BadFormulaURL(t *testing.T) {
|
||||
var p Provisioner
|
||||
config := testConfig()
|
||||
|
||||
config["formulas"] = []string{
|
||||
"git::https://github.com/org/some-formula.git//",
|
||||
}
|
||||
|
||||
err := p.Prepare(config)
|
||||
if err == nil {
|
||||
t.Fatalf("Expected invalid formula URL: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestProvisionerPrepare_ValidFormulaURLs(t *testing.T) {
|
||||
|
||||
var p Provisioner
|
||||
config := testConfig()
|
||||
|
||||
config["formulas"] = []string{
|
||||
"git::https://github.com/org/some-formula.git//example",
|
||||
"git@github.com:org/some-formula.git//example",
|
||||
}
|
||||
|
||||
err := p.Prepare(config)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error in formula URLs: %s", err)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue