Skip to content

Commit

Permalink
Fix tests failure introduced by the mime type detection
Browse files Browse the repository at this point in the history
Commit 4f64330 changes some mime types
of responses to text/plain.
The commit also FIXED the "No newline at end of file" warning in a test
data for QHttpServerResponder.

Change-Id: I9b6b1878a2b61bf80db1e39b81ae75c4cedce615
Reviewed-by: Edward Welbourne <[email protected]>
  • Loading branch information
Tasuku Suzuki committed May 9, 2019
1 parent d542f7e commit f72ced1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
48 changes: 24 additions & 24 deletions tests/auto/qhttpserver/tst_qhttpserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ void tst_QHttpServer::routeGet_data()
QTest::addRow("hello world")
<< "/"
<< 200
<< "text/html"
<< "text/plain"
<< "Hello world get";

QTest::addRow("test msg")
Expand All @@ -221,19 +221,19 @@ void tst_QHttpServer::routeGet_data()
QTest::addRow("arg:int")
<< "/page/10"
<< 200
<< "text/html"
<< "text/plain"
<< "page: 10";

QTest::addRow("arg:-int")
<< "/page/-10"
<< 200
<< "text/html"
<< "text/plain"
<< "page: -10";

QTest::addRow("arg:uint")
<< "/page/10/detail"
<< 200
<< "text/html"
<< "text/plain"
<< "page: 10 detail";

QTest::addRow("arg:-uint")
Expand All @@ -245,60 +245,60 @@ void tst_QHttpServer::routeGet_data()
QTest::addRow("arg:string")
<< "/user/test"
<< 200
<< "text/html"
<< "text/plain"
<< "test";

QTest::addRow("arg:string")
<< "/user/test test ,!a+."
<< 200
<< "text/html"
<< "text/plain"
<< "test test ,!a+.";

QTest::addRow("arg:string,ba")
<< "/user/james/bond"
<< 200
<< "text/html"
<< "text/plain"
<< "james-bond";

QTest::addRow("arg:url")
<< "/test/api/v0/cmds?val=1"
<< 200
<< "text/html"
<< "text/plain"
<< "path: api/v0/cmds";

QTest::addRow("arg:float 5.1")
<< "/api/v5.1"
<< 200
<< "text/html"
<< "text/plain"
<< "api 5.1v";

QTest::addRow("arg:float 5.")
<< "/api/v5."
<< 200
<< "text/html"
<< "text/plain"
<< "api 5v";

QTest::addRow("arg:float 6.0")
<< "/api/v6.0"
<< 200
<< "text/html"
<< "text/plain"
<< "api 6v";

QTest::addRow("arg:float,uint")
<< "/api/v5.1/user/10"
<< 200
<< "text/html"
<< "text/plain"
<< "api 5.1v, user id - 10";

QTest::addRow("arg:float,uint,query")
<< "/api/v5.2/user/11/settings?role=admin" << 200
<< "text/html"
<< "text/plain"
<< "api 5.2v, user id - 11, set settings role=admin#''";

// The fragment isn't actually sent via HTTP (it's information for the user agent)
QTest::addRow("arg:float,uint, query+fragment")
<< "/api/v5.2/user/11/settings?role=admin#tag"
<< 200 << "text/html"
<< 200 << "text/plain"
<< "api 5.2v, user id - 11, set settings role=admin#''";

QTest::addRow("custom route rule")
Expand All @@ -310,19 +310,19 @@ void tst_QHttpServer::routeGet_data()
QTest::addRow("custom route rule + query")
<< "/custom/10?key=11&g=1"
<< 200
<< "text/html"
<< "text/plain"
<< "Custom router rule: 10, key=11";

QTest::addRow("custom route rule + query key req")
<< "/custom/10?g=1&key=12"
<< 200
<< "text/html"
<< "text/plain"
<< "Custom router rule: 10, key=12";

QTest::addRow("post-and-get, get")
<< "/post-and-get"
<< 200
<< "text/html"
<< "text/plain"
<< "Hello world get";

QTest::addRow("invalid-rule-method, get")
Expand All @@ -334,13 +334,13 @@ void tst_QHttpServer::routeGet_data()
QTest::addRow("check custom type, data=1")
<< "/check-custom-type/1"
<< 200
<< "text/html"
<< "text/plain"
<< "data = 1";

QTest::addRow("any, get")
<< "/any"
<< 200
<< "text/html"
<< "text/plain"
<< "Get";
}

Expand Down Expand Up @@ -382,7 +382,7 @@ void tst_QHttpServer::routeKeepAlive()
auto checkReply = [] (QNetworkReply *reply, const QString &response) {
QTRY_VERIFY(reply->isFinished());

QCOMPARE(reply->header(QNetworkRequest::ContentTypeHeader), "text/html");
QCOMPARE(reply->header(QNetworkRequest::ContentTypeHeader), "text/plain");
QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
QCOMPARE(reply->readAll(), response);
};
Expand Down Expand Up @@ -431,21 +431,21 @@ void tst_QHttpServer::routePost_data()
QTest::addRow("hello world")
<< "/"
<< 200
<< "text/html"
<< "text/plain"
<< ""
<< "Hello world post";

QTest::addRow("post-and-get, post")
<< "/post-and-get"
<< 200
<< "text/html"
<< "text/plain"
<< ""
<< "Hello world post";

QTest::addRow("any, post")
<< "/any"
<< 200
<< "text/html"
<< "text/plain"
<< ""
<< "Post";

Expand Down Expand Up @@ -506,7 +506,7 @@ void tst_QHttpServer::routeDelete_data()
QTest::addRow("any, delete")
<< "/any"
<< 200
<< "text/html"
<< "text/plain"
<< "Delete";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ void tst_QHttpServerResponder::writeFile()

QCOMPARE(reply->header(QNetworkRequest::ContentTypeHeader), type);
QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), code);
QCOMPARE(reply->readAll(), data);
QCOMPARE(reply->readAll().trimmed(), data);

QCOMPARE(spyDestroyIoDevice.count(), 1);
}
Expand Down

0 comments on commit f72ced1

Please sign in to comment.