Merge pull request #12591 from backstage/rugvip/carriage
techdocs-backend: fix http mock in cacheMiddleware test
This commit is contained in:
+14
-11
@@ -23,17 +23,20 @@ import { createCacheMiddleware, TechDocsCache } from '.';
|
||||
* Mocks cached HTTP response.
|
||||
*/
|
||||
const getMockHttpResponseFor = (content: string): Buffer => {
|
||||
return Buffer.concat([
|
||||
Buffer.from(`HTTP/1.1 200 OK
|
||||
Content-Type: text/plain; charset=utf-8
|
||||
Accept-Ranges: bytes
|
||||
Cache-Control: public, max-age=0
|
||||
Last-Modified: Sat, 1 Jul 2021 12:00:00 GMT
|
||||
Date: Sat, 1 Jul 2021 12:00:00 GMT
|
||||
Connection: close
|
||||
Content-Length: ${content.length}\n\n`),
|
||||
Buffer.from(content),
|
||||
]);
|
||||
return Buffer.from(
|
||||
[
|
||||
'HTTP/1.1 200 OK',
|
||||
'Content-Type: text/plain; charset=utf-8',
|
||||
'Accept-Ranges: bytes',
|
||||
'Cache-Control: public, max-age=0',
|
||||
'Last-Modified: Sat, 1 Jul 2021 12:00:00 GMT',
|
||||
'Date: Sat, 1 Jul 2021 12:00:00 GMT',
|
||||
'Connection: close',
|
||||
`Content-Length: ${content.length}`,
|
||||
'',
|
||||
content,
|
||||
].join('\r\n'),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -56,17 +56,20 @@ const MockTechDocsCache = {
|
||||
TechDocsCache.fromConfig = () => MockTechDocsCache;
|
||||
|
||||
const getMockHttpResponseFor = (content: string): Buffer => {
|
||||
return Buffer.concat([
|
||||
Buffer.from(`HTTP/1.1 200 OK
|
||||
Content-Type: text/plain; charset=utf-8
|
||||
Accept-Ranges: bytes
|
||||
Cache-Control: public, max-age=0
|
||||
Last-Modified: Sat, 1 Jul 2021 12:00:00 GMT
|
||||
Date: Sat, 1 Jul 2021 12:00:00 GMT
|
||||
Connection: close
|
||||
Content-Length: ${content.length}\n\n`),
|
||||
Buffer.from(content),
|
||||
]);
|
||||
return Buffer.from(
|
||||
[
|
||||
'HTTP/1.1 200 OK',
|
||||
'Content-Type: text/plain; charset=utf-8',
|
||||
'Accept-Ranges: bytes',
|
||||
'Cache-Control: public, max-age=0',
|
||||
'Last-Modified: Sat, 1 Jul 2021 12:00:00 GMT',
|
||||
'Date: Sat, 1 Jul 2021 12:00:00 GMT',
|
||||
'Connection: close',
|
||||
`Content-Length: ${content.length}`,
|
||||
'',
|
||||
content,
|
||||
].join('\r\n'),
|
||||
);
|
||||
};
|
||||
|
||||
const createApp = async (options: RouterOptions) => {
|
||||
|
||||
Reference in New Issue
Block a user