mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Improve test coverage for http service.
This commit is contained in:
parent
6d0ac35db9
commit
9bd8b363b3
4 changed files with 244 additions and 55 deletions
|
@ -89,24 +89,6 @@ srs_error_t MockMSegmentsReader::read(void* buf, size_t size, ssize_t* nread)
|
|||
return err;
|
||||
}
|
||||
|
||||
class MockResponseWriter : virtual public ISrsHttpResponseWriter, virtual public ISrsHttpHeaderFilter
|
||||
{
|
||||
public:
|
||||
SrsHttpResponseWriter* w;
|
||||
MockBufferIO io;
|
||||
public:
|
||||
MockResponseWriter();
|
||||
virtual ~MockResponseWriter();
|
||||
public:
|
||||
virtual srs_error_t final_request();
|
||||
virtual SrsHttpHeader* header();
|
||||
virtual srs_error_t write(char* data, int size);
|
||||
virtual srs_error_t writev(const iovec* iov, int iovcnt, ssize_t* pnwrite);
|
||||
virtual void write_header(int code);
|
||||
public:
|
||||
virtual srs_error_t filter(SrsHttpHeader* h);
|
||||
};
|
||||
|
||||
MockResponseWriter::MockResponseWriter()
|
||||
{
|
||||
w = new SrsHttpResponseWriter(&io);
|
||||
|
@ -221,12 +203,6 @@ bool _mock_srs_path_not_exists(std::string /*path*/)
|
|||
return false;
|
||||
}
|
||||
|
||||
#define __MOCK_HTTP_EXPECT_STREQ(status, text, w) \
|
||||
EXPECT_STREQ(mock_http_response(status, text).c_str(), HELPER_BUFFER2STR(&w.io.out_buffer).c_str())
|
||||
|
||||
#define __MOCK_HTTP_EXPECT_STREQ2(status, text, w) \
|
||||
EXPECT_STREQ(mock_http_response2(status, text).c_str(), HELPER_BUFFER2STR(&w.io.out_buffer).c_str())
|
||||
|
||||
VOID TEST(ProtocolHTTPTest, StatusCode2Text)
|
||||
{
|
||||
EXPECT_STREQ(SRS_CONSTS_HTTP_OK_str, srs_generate_http_status_text(SRS_CONSTS_HTTP_OK).c_str());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue