common/ImageType: move to the store package

This is now only used for marshalling in the store, so keep the logic
where it is used.

Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
Tom Gundersen 2020-05-11 23:23:30 +02:00
parent 1fd3b9d543
commit 2c3790f20c
4 changed files with 116 additions and 146 deletions

View file

@ -0,0 +1,23 @@
package store
import (
"encoding/json"
"testing"
)
func TestImageType_UnmarshalJSON(t *testing.T) {
dict := struct {
ImageTypes []imageType `json:"image_types"`
}{}
input := `{"image_types":["qcow2", "Azure"]}`
err := json.Unmarshal([]byte(input), &dict)
if err != nil {
t.Fatal(err)
}
if dict.ImageTypes[0] != Qcow2Generic {
t.Fatal("failed to umarshal image type qcow2; got tag:", dict.ImageTypes[0])
}
if dict.ImageTypes[1] != Azure {
t.Fatal("failed to umarshal image type Azure; got tag:", dict.ImageTypes[0])
}
}