publish repo from result/ directory

Update tests
This commit is contained in:
Johan Haals
2021-01-27 09:12:36 +01:00
parent add5ce1350
commit 85365cc23d
7 changed files with 29 additions and 27 deletions
@@ -53,7 +53,7 @@ describe('Azure Publisher', () => {
storePath: 'https://dev.azure.com/organisation/project/_git/repo',
owner: 'bob',
},
directory: '/tmp/test',
workspacePath: '/tmp/test',
logger,
});
@@ -74,7 +74,7 @@ describe('Azure Publisher', () => {
'project',
);
expect(helpers.initRepoAndPush).toHaveBeenCalledWith({
dir: '/tmp/test',
dir: '/tmp/test/result',
remoteUrl: 'https://dev.azure.com/organization/project/_git/repo',
auth: { username: 'notempty', password: 'fake-azure-token' },
logger,
@@ -21,6 +21,7 @@ import { initRepoAndPush } from './helpers';
import { AzureIntegrationConfig } from '@backstage/integration';
import parseGitUrl from 'git-url-parse';
import { getPersonalAccessTokenHandler, WebApi } from 'azure-devops-node-api';
import path from 'path';
export class AzurePublisher implements PublisherBase {
static async fromConfig(config: AzureIntegrationConfig) {
@@ -34,7 +35,7 @@ export class AzurePublisher implements PublisherBase {
async publish({
values,
directory,
workspacePath,
logger,
}: PublisherOptions): Promise<PublisherResult> {
const { owner, name, organization, resource } = parseGitUrl(
@@ -56,7 +57,7 @@ export class AzurePublisher implements PublisherBase {
const catalogInfoUrl = `${remoteUrl}?path=%2Fcatalog-info.yaml`;
await initRepoAndPush({
dir: directory,
dir: path.join(workspacePath, 'result'),
remoteUrl,
auth: {
username: 'notempty',
@@ -69,7 +69,7 @@ describe('Bitbucket Publisher', () => {
storePath: 'https://bitbucket.org/project/repo',
owner: 'bob',
},
directory: '/tmp/test',
workspacePath: '/tmp/test',
logger: logger,
});
@@ -80,7 +80,7 @@ describe('Bitbucket Publisher', () => {
});
expect(initRepoAndPush).toHaveBeenCalledWith({
dir: '/tmp/test',
dir: '/tmp/test/result',
remoteUrl: 'https://bitbucket.org/project/repo',
auth: { username: 'fake-user', password: 'fake-token' },
logger: logger,
@@ -127,7 +127,7 @@ describe('Bitbucket Publisher', () => {
storePath: 'https://bitbucket.mycompany.com/project/repo',
owner: 'bob',
},
directory: '/tmp/test',
workspacePath: '/tmp/test',
logger: logger,
});
@@ -138,7 +138,7 @@ describe('Bitbucket Publisher', () => {
});
expect(initRepoAndPush).toHaveBeenCalledWith({
dir: '/tmp/test',
dir: '/tmp/test/result',
remoteUrl: 'https://bitbucket.mycompany.com/scm/project/repo',
auth: { username: 'x-token-auth', password: 'fake-token' },
logger: logger,
@@ -19,6 +19,7 @@ import { initRepoAndPush } from './helpers';
import fetch from 'cross-fetch';
import { BitbucketIntegrationConfig } from '@backstage/integration';
import parseGitUrl from 'git-url-parse';
import path from 'path';
// TODO(blam): We should probably start to use a bitbucket client here that we can change
// the baseURL to point at on-prem or public bitbucket versions like we do for
@@ -45,7 +46,7 @@ export class BitbucketPublisher implements PublisherBase {
async publish({
values,
directory,
workspacePath,
logger,
}: PublisherOptions): Promise<PublisherResult> {
const { owner: project, name } = parseGitUrl(values.storePath);
@@ -58,7 +59,7 @@ export class BitbucketPublisher implements PublisherBase {
});
await initRepoAndPush({
dir: directory,
dir: path.join(workspacePath, 'result'),
remoteUrl: result.remoteUrl,
auth: {
username: this.config.username ? this.config.username : 'x-token-auth',
@@ -64,7 +64,7 @@ describe('GitHub Publisher', () => {
owner: 'bob',
access: 'blam/team',
},
directory: '/tmp/test',
workspacePath: '/tmp/test',
logger,
});
@@ -89,7 +89,7 @@ describe('GitHub Publisher', () => {
permission: 'admin',
});
expect(initRepoAndPush).toHaveBeenCalledWith({
dir: '/tmp/test',
dir: '/tmp/test/result',
remoteUrl: 'https://github.com/backstage/backstage.git',
auth: { username: 'fake-token', password: 'x-oauth-basic' },
logger,
@@ -122,7 +122,7 @@ describe('GitHub Publisher', () => {
owner: 'bob',
access: 'blam',
},
directory: '/tmp/test',
workspacePath: '/tmp/test',
logger,
});
@@ -140,7 +140,7 @@ describe('GitHub Publisher', () => {
expect(mockGithubClient.repos.addCollaborator).not.toHaveBeenCalled();
expect(initRepoAndPush).toHaveBeenCalledWith({
dir: '/tmp/test',
dir: '/tmp/test/result',
remoteUrl: 'https://github.com/backstage/backstage.git',
auth: { username: 'fake-token', password: 'x-oauth-basic' },
logger,
@@ -175,7 +175,7 @@ describe('GitHub Publisher', () => {
access: 'bob',
description: 'description',
},
directory: '/tmp/test',
workspacePath: '/tmp/test',
logger,
});
@@ -198,7 +198,7 @@ describe('GitHub Publisher', () => {
permission: 'admin',
});
expect(initRepoAndPush).toHaveBeenCalledWith({
dir: '/tmp/test',
dir: '/tmp/test/result',
remoteUrl: 'https://github.com/backstage/backstage.git',
auth: { username: 'fake-token', password: 'x-oauth-basic' },
logger,
@@ -233,7 +233,7 @@ describe('GitHub Publisher', () => {
storePath: 'https://github.com/blam/test',
owner: 'bob',
},
directory: '/tmp/test',
workspacePath: '/tmp/test',
logger,
});
@@ -249,7 +249,7 @@ describe('GitHub Publisher', () => {
visibility: 'internal',
});
expect(initRepoAndPush).toHaveBeenCalledWith({
dir: '/tmp/test',
dir: '/tmp/test/result',
remoteUrl: 'https://github.com/backstage/backstage.git',
auth: { username: 'fake-token', password: 'x-oauth-basic' },
logger,
@@ -283,7 +283,7 @@ describe('GitHub Publisher', () => {
storePath: 'https://github.com/blam/test',
owner: 'bob',
},
directory: '/tmp/test',
workspacePath: '/tmp/test',
logger,
});
@@ -299,7 +299,7 @@ describe('GitHub Publisher', () => {
private: true,
});
expect(initRepoAndPush).toHaveBeenCalledWith({
dir: '/tmp/test',
dir: '/tmp/test/result',
remoteUrl: 'https://github.com/backstage/backstage.git',
auth: { username: 'fake-token', password: 'x-oauth-basic' },
logger,
@@ -68,7 +68,7 @@ describe('GitLab Publisher', () => {
storePath: 'https://gitlab.com/blam/test',
owner: 'bob',
},
directory: '/tmp/test',
workspacePath: '/tmp/test',
logger,
});
@@ -85,7 +85,7 @@ describe('GitLab Publisher', () => {
name: 'test',
});
expect(initRepoAndPush).toHaveBeenCalledWith({
dir: '/tmp/test',
dir: '/tmp/test/result',
remoteUrl: 'mockclone',
auth: { username: 'oauth2', password: 'fake-token' },
logger,
@@ -111,7 +111,7 @@ describe('GitLab Publisher', () => {
storePath: 'https://gitlab.com/blam/test',
owner: 'bob',
},
directory: '/tmp/test',
workspacePath: '/tmp/test',
logger,
});
@@ -125,7 +125,7 @@ describe('GitLab Publisher', () => {
name: 'test',
});
expect(initRepoAndPush).toHaveBeenCalledWith({
dir: '/tmp/test',
dir: '/tmp/test/result',
remoteUrl: 'mockclone',
auth: { username: 'oauth2', password: 'fake-token' },
logger,
@@ -19,7 +19,7 @@ import { Gitlab } from '@gitbeaker/node';
import { Gitlab as GitlabClient } from '@gitbeaker/core';
import { initRepoAndPush } from './helpers';
import parseGitUrl from 'git-url-parse';
import path from 'path';
import { GitLabIntegrationConfig } from '@backstage/integration';
export class GitlabPublisher implements PublisherBase {
@@ -38,7 +38,7 @@ export class GitlabPublisher implements PublisherBase {
async publish({
values,
directory,
workspacePath,
logger,
}: PublisherOptions): Promise<PublisherResult> {
const { owner, name } = parseGitUrl(values.storePath);
@@ -49,7 +49,7 @@ export class GitlabPublisher implements PublisherBase {
});
await initRepoAndPush({
dir: directory,
dir: path.join(workspacePath, 'result'),
remoteUrl,
auth: {
username: 'oauth2',