diff options
author | Flavio Castelli <fcastelli@suse.com> | 2017-03-02 23:06:24 +0100 |
---|---|---|
committer | Alvaro <alvaro.saurin@gmail.com> | 2017-03-03 09:50:04 +0100 |
commit | 01d6e3972e69e1158fba260b97f47921b3d7a4c4 (patch) | |
tree | 1df6c1d88c741801eb8295e1ec02bc8c151f1145 /libvirt/volume_def_test.go | |
parent | dea5495901aa84488b7b446a6708aeccf00c680a (diff) | |
download | terraform-provider-libvirt-01d6e3972e69e1158fba260b97f47921b3d7a4c4.tar terraform-provider-libvirt-01d6e3972e69e1158fba260b97f47921b3d7a4c4.tar.gz |
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 <fcastelli@suse.com>
Diffstat (limited to 'libvirt/volume_def_test.go')
-rw-r--r-- | libvirt/volume_def_test.go | 27 |
1 files changed, 27 insertions, 0 deletions
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()) +} |