Allow more general parameters to be made by client. Also fix style and comments.

This commit is contained in:
Daniel Smith
2014-08-05 15:23:33 -07:00
parent 283fdba6ab
commit 097147545c
4 changed files with 79 additions and 38 deletions

View File

@@ -49,7 +49,7 @@ func TestDoRequestNewWay(t *testing.T) {
obj, err := s.Verb("POST").
Path("foo/bar").
Path("baz").
ParseSelector("name=foo").
ParseSelectorParam("labels", "name=foo").
Timeout(time.Second).
Body([]byte(reqBody)).
Do().Get()
@@ -87,7 +87,7 @@ func TestDoRequestNewWayReader(t *testing.T) {
obj, err := s.Verb("POST").
Path("foo/bar").
Path("baz").
Selector(labels.Set{"name": "foo"}.AsSelector()).
SelectorParam("labels", labels.Set{"name": "foo"}.AsSelector()).
Sync(false).
Timeout(time.Second).
Body(bytes.NewBuffer(reqBodyExpected)).
@@ -127,7 +127,7 @@ func TestDoRequestNewWayObj(t *testing.T) {
obj, err := s.Verb("POST").
Path("foo/bar").
Path("baz").
Selector(labels.Set{"name": "foo"}.AsSelector()).
SelectorParam("labels", labels.Set{"name": "foo"}.AsSelector()).
Timeout(time.Second).
Body(reqObj).
Do().Get()
@@ -180,7 +180,7 @@ func TestDoRequestNewWayFile(t *testing.T) {
obj, err := s.Verb("POST").
Path("foo/bar").
Path("baz").
ParseSelector("name=foo").
ParseSelectorParam("labels", "name=foo").
Timeout(time.Second).
Body(file.Name()).
Do().Get()
@@ -244,6 +244,26 @@ func TestSync(t *testing.T) {
}
}
func TestUintParam(t *testing.T) {
table := []struct {
name string
testVal uint64
expectStr string
}{
{"foo", 31415, "?foo=31415"},
{"bar", 42, "?bar=42"},
{"baz", 0, "?baz=0"},
}
for _, item := range table {
c := New("", nil)
r := c.Get().AbsPath("").UintParam(item.name, item.testVal)
if e, a := item.expectStr, r.finalURL(); e != a {
t.Errorf("expected %v, got %v", e, a)
}
}
}
func TestSetPollPeriod(t *testing.T) {
c := New("", nil)
r := c.Get()