From 01d6e3972e69e1158fba260b97f47921b3d7a4c4 Mon Sep 17 00:00:00 2001 From: Flavio Castelli Date: Thu, 2 Mar 2017 23:06:24 +0100 Subject: Improve code coverage Improve code coverage results by writing some unit tests. These are really the low hanging fruits, more should come later. Signed-off-by: Flavio Castelli --- libvirt/volume_def_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 libvirt/volume_def_test.go (limited to 'libvirt/volume_def_test.go') diff --git a/libvirt/volume_def_test.go b/libvirt/volume_def_test.go new file mode 100644 index 00000000..6936154c --- /dev/null +++ b/libvirt/volume_def_test.go @@ -0,0 +1,27 @@ +package libvirt + +import ( + "bytes" + "encoding/xml" + "testing" + + "github.com/davecgh/go-spew/spew" +) + +func init() { + spew.Config.Indent = "\t" +} + +func TestDefaultVolumeMarshall(t *testing.T) { + b := newDefVolume() + prettyB := spew.Sdump(b) + t.Logf("Parsed default volume:\n%s", prettyB) + + 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)) + } + t.Logf("Marshalled default volume:\n%s", buf.String()) +} -- cgit v1.2.3