fix to BuildQueryString; params.go unit tests
diff --git a/params.go b/params.go
index f10c2db..c01c9e5 100644
--- a/params.go
+++ b/params.go
@@ -94,7 +94,7 @@
}
// URL encode the string for safety.
- s := url.QueryEscape(strings.Join(optsSlice, "&"))
+ s := strings.Join(optsSlice, "&")
if s != "" {
s = "?" + s
}
diff --git a/params_test.go b/params_test.go
new file mode 100644
index 0000000..112850d
--- /dev/null
+++ b/params_test.go
@@ -0,0 +1,42 @@
+package gophercloud
+
+import (
+ "net/url"
+ "testing"
+
+ th "github.com/rackspace/gophercloud/testhelper"
+)
+
+func TestMaybeStringWithNonEmptyString(t *testing.T) {
+ testString := "carol"
+ expected := &testString
+ actual := MaybeString("carol")
+ th.CheckDeepEquals(t, actual, expected)
+}
+
+func TestMaybeStringWithEmptyString(t *testing.T) {
+ var expected *string
+ actual := MaybeString("")
+ th.CheckDeepEquals(t, actual, expected)
+}
+
+func TestBuildQueryStringWithPointerToStruct(t *testing.T) {
+ expected := &url.URL{
+ RawQuery: "j=2&r=red",
+ }
+
+ type Opts struct {
+ J int `q:"j"`
+ R string `q:"r"`
+ C bool
+ }
+
+ opts := Opts{J: 2, R: "red"}
+
+ actual, err := BuildQueryString(opts)
+ if err != nil {
+ t.Errorf("Error building query string: %v", err)
+ }
+
+ th.CheckDeepEquals(t, actual, expected)
+}