Merge branch 'personality' of github.com:doubledutch/gophercloud
Conflicts:
openstack/compute/v2/servers/requests_test.go
diff --git a/openstack/compute/v2/servers/requests_test.go b/openstack/compute/v2/servers/requests_test.go
index 1f39fe1..88cb54d 100644
--- a/openstack/compute/v2/servers/requests_test.go
+++ b/openstack/compute/v2/servers/requests_test.go
@@ -1,6 +1,8 @@
package servers
import (
+ "encoding/base64"
+ "encoding/json"
"net/http"
"testing"
@@ -334,3 +336,38 @@
_, err := CreateImage(client.ServiceClient(), "serverimage", CreateImageOpts{Name: "test"}).ExtractImageID()
th.AssertNoErr(t, err)
}
+
+func TestMarshalPersonality(t *testing.T) {
+ name := "/etc/test"
+ contents := []byte("asdfasdf")
+
+ personality := Personality{
+ &File{
+ Path: name,
+ Contents: contents,
+ },
+ }
+
+ data, err := json.Marshal(personality)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ var actual []map[string]string
+ err = json.Unmarshal(data, &actual)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if len(actual) != 1 {
+ t.Fatal("expected personality length 1")
+ }
+
+ if actual[0]["path"] != name {
+ t.Fatal("file path incorrect")
+ }
+
+ if actual[0]["contents"] != base64.StdEncoding.EncodeToString(contents) {
+ t.Fatal("file contents incorrect")
+ }
+}