1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Add TestEndToEndErrorMessage

Test if error messages from daemon are not empty strings.

Confirmed it fails without af323c7.

 --- FAIL: TestEndToEndErrorMessage (0.03s)
 	api_test.go:2266: Empty response error message.

Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
This commit is contained in:
Toshiaki Makita 2015-09-02 16:19:19 +09:00
parent 5d8db5cec2
commit 36e7a8b168

View file

@ -2239,6 +2239,34 @@ func TestEndToEnd(t *testing.T) {
}
}
func TestEndToEndErrorMessage(t *testing.T) {
defer osl.SetupTestOSContext(t)()
rsp := newWriter()
c, err := libnetwork.New()
if err != nil {
t.Fatal(err)
}
handleRequest := NewHTTPHandler(c)
body := []byte{}
lr := newLocalReader(body)
req, err := http.NewRequest("POST", "/v1.19/networks", lr)
if err != nil {
t.Fatal(err)
}
handleRequest(rsp, req)
if len(rsp.body) == 0 {
t.Fatalf("Empty response body.")
}
empty := []byte("\"\"")
if bytes.Equal(empty, bytes.TrimSpace(rsp.body)) {
t.Fatalf("Empty response error message.")
}
}
type bre struct{}
func (b *bre) Error() string {