Skip to content

Commit

Permalink
Add more tests for serializers
Browse files Browse the repository at this point in the history
  • Loading branch information
ryansb committed Dec 6, 2015
1 parent c5511c2 commit bf62a00
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package fargo_test
// MIT Licensed (see README.md) - Copyright (c) 2013 Hudl <@Hudl>

import (
"encoding/xml"
"github.com/hudl/fargo"
. "github.com/smartystreets/goconvey/convey"
"strconv"
Expand Down Expand Up @@ -58,3 +59,28 @@ func TestGetFloat(t *testing.T) {
})
})
}

func TestSerializeMeta(t *testing.T) {
Convey("Given an instance", t, func() {
instance := new(fargo.Instance)
Convey("With metadata", func() {
instance.SetMetadataString("test", "value")
Convey("Serializing results in correct JSON", func() {
b, err := instance.Metadata.MarshalJSON()
So(err, ShouldBeNil)
So(string(b), ShouldEqual, "{\"test\":\"value\"}")
})
Convey("Serializing results in correct XML", func() {
b, err := xml.Marshal(instance.Metadata)
So(err, ShouldBeNil)
So(string(b), ShouldEqual, "<InstanceMetadata><test>value</test></InstanceMetadata>")
})
Convey("Blank metadata results in blank XML", func() {
metadata := new(fargo.InstanceMetadata)
b, err := xml.Marshal(metadata)
So(err, ShouldBeNil)
So(string(b), ShouldEqual, "<InstanceMetadata></InstanceMetadata>")
})
})
})
}

0 comments on commit bf62a00

Please sign in to comment.