godeps: bump go-etcd to 6aa2da5

This commit is contained in:
Yicheng Qin
2014-12-30 20:12:48 -08:00
parent 7273a861a6
commit dc863459f8
3 changed files with 28 additions and 4 deletions

View File

@@ -379,11 +379,13 @@ func buildValues(value string, ttl uint64) url.Values {
return v
}
// convert key string to http path exclude version
// convert key string to http path exclude version, including URL escaping
// for example: key[foo] -> path[keys/foo]
// key[/%z] -> path[keys/%25z]
// key[/] -> path[keys/]
func keyToPath(key string) string {
p := path.Join("keys", key)
// URL-escape our key, except for slashes
p := strings.Replace(url.QueryEscape(path.Join("keys", key)), "%2F", "/", -1)
// corner case: if key is "/" or "//" ect
// path join will clear the tailing "/"

View File

@@ -0,0 +1,22 @@
package etcd
import "testing"
func TestKeyToPath(t *testing.T) {
tests := []struct {
key string
wpath string
}{
{"", "keys/"},
{"foo", "keys/foo"},
{"foo/bar", "keys/foo/bar"},
{"%z", "keys/%25z"},
{"/", "keys/"},
}
for i, tt := range tests {
path := keyToPath(tt.key)
if path != tt.wpath {
t.Errorf("#%d: path = %s, want %s", i, path, tt.wpath)
}
}
}