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:
parent
5d8db5cec2
commit
36e7a8b168
1 changed files with 28 additions and 0 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue