mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #1456 from AkihiroSuda/fix-test-failures
Fix test failures
This commit is contained in:
commit
1b237a7a0c
2 changed files with 15 additions and 9 deletions
|
@ -1667,9 +1667,8 @@ func (f *localResponseWriter) WriteHeader(c int) {
|
||||||
f.statusCode = c
|
f.statusCode = c
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestwriteJSON(t *testing.T) {
|
func testWriteJSON(t *testing.T, testCode int, testData interface{}) {
|
||||||
testCode := 55
|
testDataMarshalled, err := json.Marshal(testData)
|
||||||
testData, err := json.Marshal("test data")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -1679,10 +1678,17 @@ func TestwriteJSON(t *testing.T) {
|
||||||
if rsp.statusCode != testCode {
|
if rsp.statusCode != testCode {
|
||||||
t.Fatalf("writeJSON() failed to set the status code. Expected %d. Got %d", testCode, rsp.statusCode)
|
t.Fatalf("writeJSON() failed to set the status code. Expected %d. Got %d", testCode, rsp.statusCode)
|
||||||
}
|
}
|
||||||
if !bytes.Equal(testData, rsp.body) {
|
// writeJSON calls json.Encode and it appends '\n' to the result,
|
||||||
t.Fatalf("writeJSON() failed to set the body. Expected %s. Got %s", testData, rsp.body)
|
// while json.Marshal not
|
||||||
|
expected := append(testDataMarshalled, byte('\n'))
|
||||||
|
if !bytes.Equal(expected, rsp.body) {
|
||||||
|
t.Fatalf("writeJSON() failed to set the body. Expected %q. Got %q", expected, rsp.body)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWriteJSON(t *testing.T) {
|
||||||
|
testWriteJSON(t, 55, "test data as string")
|
||||||
|
testWriteJSON(t, 55, []byte("test data as bytes"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHttpHandlerUninit(t *testing.T) {
|
func TestHttpHandlerUninit(t *testing.T) {
|
||||||
|
|
|
@ -1545,7 +1545,7 @@ func TestLeaveAll(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestontainerInvalidLeave(t *testing.T) {
|
func TestContainerInvalidLeave(t *testing.T) {
|
||||||
if !testutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
defer testutils.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
}
|
}
|
||||||
|
@ -1595,11 +1595,11 @@ func TestontainerInvalidLeave(t *testing.T) {
|
||||||
t.Fatalf("Failed with unexpected error type: %T. Desc: %s", err, err.Error())
|
t.Fatalf("Failed with unexpected error type: %T. Desc: %s", err, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ep.Leave(nil); err == nil {
|
if err = ep.Leave(nil); err == nil {
|
||||||
t.Fatalf("Expected to fail leave nil Sandbox")
|
t.Fatalf("Expected to fail leave nil Sandbox")
|
||||||
}
|
}
|
||||||
if _, ok := err.(types.BadRequestError); !ok {
|
if _, ok := err.(types.BadRequestError); !ok {
|
||||||
t.Fatalf("Unexpected error type returned: %T", err)
|
t.Fatalf("Unexpected error type returned: %T. Desc: %s", err, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
fsbx := &fakeSandbox{}
|
fsbx := &fakeSandbox{}
|
||||||
|
@ -1607,7 +1607,7 @@ func TestontainerInvalidLeave(t *testing.T) {
|
||||||
t.Fatalf("Expected to fail leave with invalid Sandbox")
|
t.Fatalf("Expected to fail leave with invalid Sandbox")
|
||||||
}
|
}
|
||||||
if _, ok := err.(types.BadRequestError); !ok {
|
if _, ok := err.(types.BadRequestError); !ok {
|
||||||
t.Fatalf("Unexpected error type returned: %T", err)
|
t.Fatalf("Unexpected error type returned: %T. Desc: %s", err, err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue