package libvirt import ( "bytes" "encoding/xml" "testing" "github.com/davecgh/go-spew/spew" ) func init() { spew.Config.Indent = "\t" } func TestVolumeUnmarshal(t *testing.T) { xmlDesc := ` caasp_master.img /home/user/.libvirt/images/image.img 42949672960 900800512 /home/user/.libvirt/images/image.img 0644 480 473 1488789260.012293492 1488802938.454893390 1488802938.454893390 /home/user/.libvirt/images/image.img 0644 480 473 1488541864.606322102 1488541858.638308597 1488541864.526321921 ` _, err := newDefVolumeFromXML(xmlDesc) if err != nil { t.Fatalf("could not unmarshall volume definition:\n%s", err) } } func TestDefaultVolumeMarshall(t *testing.T) { b := newDefVolume() buf := new(bytes.Buffer) enc := xml.NewEncoder(buf) enc.Indent(" ", " ") if err := enc.Encode(b); err != nil { t.Fatalf("could not marshall this:\n%s", spew.Sdump(b)) } }