Download tar.gz archives for Bitbucket

Signed-off-by: Mathias Åhsberg <mathias.ahsberg@resurs.se>
This commit is contained in:
Mathias Åhsberg
2021-06-04 12:46:42 +00:00
parent 18ddc1b318
commit eda9dbd5fa
9 changed files with 27 additions and 21 deletions
@@ -90,7 +90,7 @@ describe('BitbucketUrlReader', () => {
'src',
'reading',
'__fixtures__',
'bitbucket-repo-with-commit-hash.zip',
'bitbucket-repo-with-commit-hash.tar.gz',
),
);
@@ -99,7 +99,7 @@ describe('BitbucketUrlReader', () => {
'src',
'reading',
'__fixtures__',
'bitbucket-server-repo.zip',
'bitbucket-server-repo.tar.gz',
),
);
@@ -119,14 +119,14 @@ describe('BitbucketUrlReader', () => {
),
),
rest.get(
'https://bitbucket.org/backstage/mock/get/master.zip',
'https://bitbucket.org/backstage/mock/get/master.tgz',
(_, res, ctx) =>
res(
ctx.status(200),
ctx.set('Content-Type', 'application/zip'),
ctx.set(
'content-disposition',
'attachment; filename=backstage-mock-12ab34cd56ef.zip',
'attachment; filename=backstage-mock-12ab34cd56ef.tgz',
),
ctx.body(repoBuffer),
),
@@ -142,14 +142,14 @@ describe('BitbucketUrlReader', () => {
),
),
rest.get(
'https://api.bitbucket.mycompany.net/rest/api/1.0/projects/backstage/repos/mock/archive?format=zip&prefix=mock&path=docs',
'https://api.bitbucket.mycompany.net/rest/api/1.0/projects/backstage/repos/mock/archive?format=tgz&prefix=mock&path=docs',
(_, res, ctx) =>
res(
ctx.status(200),
ctx.set('Content-Type', 'application/zip'),
ctx.set(
'content-disposition',
'attachment; filename=backstage-mock.zip',
'attachment; filename=backstage-mock.tgz',
),
ctx.body(privateBitbucketRepoBuffer),
),
@@ -177,8 +177,8 @@ describe('BitbucketUrlReader', () => {
const files = await response.files();
expect(files.length).toBe(2);
const indexMarkdownFile = await files[0].content();
const mkDocsFile = await files[1].content();
const mkDocsFile = await files[0].content();
const indexMarkdownFile = await files[1].content();
expect(indexMarkdownFile.toString()).toBe('# Test\n');
expect(mkDocsFile.toString()).toBe('site_name: Test\n');
@@ -284,7 +284,7 @@ describe('BitbucketUrlReader', () => {
'src',
'reading',
'__fixtures__',
'bitbucket-repo-with-commit-hash.zip',
'bitbucket-repo-with-commit-hash.tar.gz',
),
);
@@ -304,14 +304,14 @@ describe('BitbucketUrlReader', () => {
),
),
rest.get(
'https://bitbucket.org/backstage/mock/get/master.zip',
'https://bitbucket.org/backstage/mock/get/master.tgz',
(_, res, ctx) =>
res(
ctx.status(200),
ctx.set('Content-Type', 'application/zip'),
ctx.set(
'content-disposition',
'attachment; filename=backstage-mock-12ab34cd56ef.zip',
'attachment; filename=backstage-mock-12ab34cd56ef.tgz',
),
ctx.body(repoBuffer),
),
@@ -359,21 +359,21 @@ describe('BitbucketUrlReader', () => {
'src',
'reading',
'__fixtures__',
'bitbucket-server-repo.zip',
'bitbucket-server-repo.tar.gz',
),
);
beforeEach(() => {
worker.use(
rest.get(
'https://api.bitbucket.mycompany.net/rest/api/1.0/projects/backstage/repos/mock/archive?format=zip&prefix=mock&path=docs',
'https://api.bitbucket.mycompany.net/rest/api/1.0/projects/backstage/repos/mock/archive?format=tgz&prefix=mock&path=docs',
(_, res, ctx) =>
res(
ctx.status(200),
ctx.set('Content-Type', 'application/zip'),
ctx.set(
'content-disposition',
'attachment; filename=backstage-mock.zip',
'attachment; filename=backstage-mock.tgz',
),
ctx.body(privateBitbucketRepoBuffer),
),
@@ -126,7 +126,7 @@ export class BitbucketUrlReader implements UrlReader {
throw new Error(message);
}
return await this.deps.treeResponseFactory.fromZipArchive({
return await this.deps.treeResponseFactory.fromTarArchive({
stream: (archiveBitbucketResponse.body as unknown) as Readable,
subpath: filepath,
etag: lastCommitShortHash,