Should return an error when the box file is missing
This commit is contained in:
parent
e8c586175e
commit
6b5cf6dcb2
|
@ -226,5 +226,11 @@ func providerFromBuilderName(name string) string {
|
||||||
// Returns the Vagrant provider the box is intended for use with by
|
// Returns the Vagrant provider the box is intended for use with by
|
||||||
// reading the metadata file packaged inside the box
|
// reading the metadata file packaged inside the box
|
||||||
func providerFromVagrantBox(boxfile string) (providerName string, err error) {
|
func providerFromVagrantBox(boxfile string) (providerName string, err error) {
|
||||||
|
f, err := os.Open(boxfile)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("Error attempting to open box file: %s", err)
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,3 +197,12 @@ func TestProviderFromBuilderName(t *testing.T) {
|
||||||
t.Fatal("should convert provider")
|
t.Fatal("should convert provider")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestProviderFromVagrantBox_missing_box(t *testing.T) {
|
||||||
|
boxfile := "i_dont_exist.box"
|
||||||
|
_, err := providerFromVagrantBox(boxfile)
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("Should have error as box file does not exist")
|
||||||
|
}
|
||||||
|
t.Logf("%s", err)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue