Should return an error if the provider kv pair is not in the metadata file

This commit is contained in:
DanHam 2019-08-21 13:18:56 +01:00
parent a7603f63c7
commit aee400836f
No known key found for this signature in database
GPG Key ID: 58E79AEDD6AA987E
1 changed files with 20 additions and 0 deletions

View File

@ -327,6 +327,26 @@ func TestProviderFromVagrantBox_metadata_bad_json(t *testing.T) {
t.Logf("%s", err)
}
func TestProviderFromVagrantBox_metadata_no_provider_key(t *testing.T) {
// Bad: Create a box with no 'provider' key in the metadata.json file
files := tarFiles{
{"foo.txt", "This is a foo file"},
{"bar.txt", "This is a bar file"},
{"metadata.json", `{"cows":"moo"}`},
}
boxfile, err := createBox(files)
if err != nil {
t.Fatalf("Error creating test box: %s", err)
}
defer os.Remove(boxfile.Name())
_, err = providerFromVagrantBox(boxfile.Name())
if err == nil {
t.Fatalf("Should have error as box files metadata.json file is empty")
}
t.Logf("%s", err)
}
func TestProviderFromVagrantBox_metadata_provider_value_empty(t *testing.T) {
// Bad: The boxes metadata.json file 'provider' key has an empty value
files := tarFiles{