Should return an error when the box file is missing

This commit is contained in:
DanHam 2019-08-20 16:36:01 +01:00
parent e8c586175e
commit 6b5cf6dcb2
No known key found for this signature in database
GPG Key ID: 58E79AEDD6AA987E
2 changed files with 15 additions and 0 deletions

View File

@ -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
} }

View File

@ -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)
}