|
@@ -1100,6 +1100,7 @@ func TestBadServeKeys(t *testing.T) {
|
|
|
server etcdserver.Server
|
|
server etcdserver.Server
|
|
|
|
|
|
|
|
wcode int
|
|
wcode int
|
|
|
|
|
+ wbody string
|
|
|
}{
|
|
}{
|
|
|
{
|
|
{
|
|
|
// bad method
|
|
// bad method
|
|
@@ -1109,6 +1110,7 @@ func TestBadServeKeys(t *testing.T) {
|
|
|
&resServer{},
|
|
&resServer{},
|
|
|
|
|
|
|
|
http.StatusMethodNotAllowed,
|
|
http.StatusMethodNotAllowed,
|
|
|
|
|
+ "Method Not Allowed",
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
// bad method
|
|
// bad method
|
|
@@ -1118,6 +1120,7 @@ func TestBadServeKeys(t *testing.T) {
|
|
|
&resServer{},
|
|
&resServer{},
|
|
|
|
|
|
|
|
http.StatusMethodNotAllowed,
|
|
http.StatusMethodNotAllowed,
|
|
|
|
|
+ "Method Not Allowed",
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
// parseRequest error
|
|
// parseRequest error
|
|
@@ -1128,6 +1131,7 @@ func TestBadServeKeys(t *testing.T) {
|
|
|
&resServer{},
|
|
&resServer{},
|
|
|
|
|
|
|
|
http.StatusBadRequest,
|
|
http.StatusBadRequest,
|
|
|
|
|
+ `{"errorCode":210,"message":"Invalid POST form","cause":"missing form body","index":0}`,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
// etcdserver.Server error
|
|
// etcdserver.Server error
|
|
@@ -1137,6 +1141,17 @@ func TestBadServeKeys(t *testing.T) {
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
http.StatusInternalServerError,
|
|
http.StatusInternalServerError,
|
|
|
|
|
+ "Internal Server Error",
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ // etcdserver.Server etcd error
|
|
|
|
|
+ mustNewRequest(t, "foo"),
|
|
|
|
|
+ &errServer{
|
|
|
|
|
+ etcdErr.NewError(etcdErr.EcodeKeyNotFound, "/1/pant", 0),
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ http.StatusNotFound,
|
|
|
|
|
+ `{"errorCode":100,"message":"Key not found","cause":"/pant","index":0}`,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
// non-event/watcher response from etcdserver.Server
|
|
// non-event/watcher response from etcdserver.Server
|
|
@@ -1146,6 +1161,7 @@ func TestBadServeKeys(t *testing.T) {
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
http.StatusInternalServerError,
|
|
http.StatusInternalServerError,
|
|
|
|
|
+ "Internal Server Error",
|
|
|
},
|
|
},
|
|
|
}
|
|
}
|
|
|
for i, tt := range testBadCases {
|
|
for i, tt := range testBadCases {
|
|
@@ -1158,6 +1174,9 @@ func TestBadServeKeys(t *testing.T) {
|
|
|
if rw.Code != tt.wcode {
|
|
if rw.Code != tt.wcode {
|
|
|
t.Errorf("#%d: got code=%d, want %d", i, rw.Code, tt.wcode)
|
|
t.Errorf("#%d: got code=%d, want %d", i, rw.Code, tt.wcode)
|
|
|
}
|
|
}
|
|
|
|
|
+ if g := strings.TrimSuffix(rw.Body.String(), "\n"); g != tt.wbody {
|
|
|
|
|
+ t.Errorf("#%d: body = %s, want %s", i, g, tt.wbody)
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|