scaffolder-backend: inline @gitbeaker/node mock

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-03-12 10:24:46 +01:00
parent baf3dcccd0
commit 118acbb71b
2 changed files with 19 additions and 36 deletions
@@ -1,33 +0,0 @@
/*
* Copyright 2020 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const mockGitlabClient = {
Namespaces: {
show: jest.fn(),
},
Projects: {
create: jest.fn(),
},
Users: {
current: jest.fn(),
},
};
export class Gitlab {
constructor() {
return mockGitlabClient;
}
}
@@ -14,7 +14,6 @@
* limitations under the License.
*/
jest.mock('../helpers');
jest.mock('@gitbeaker/node');
import { createPublishGitlabAction } from './gitlab';
import { ScmIntegrations } from '@backstage/integration';
@@ -23,6 +22,25 @@ import { getVoidLogger } from '@backstage/backend-common';
import { PassThrough } from 'stream';
import { initRepoAndPush } from '../helpers';
const mockGitlabClient = {
Namespaces: {
show: jest.fn(),
},
Projects: {
create: jest.fn(),
},
Users: {
current: jest.fn(),
},
};
jest.mock('@gitbeaker/node', () => ({
Gitlab: class {
constructor() {
return mockGitlabClient;
}
},
}));
describe('publish:gitlab', () => {
const config = new ConfigReader({
integrations: {
@@ -54,8 +72,6 @@ describe('publish:gitlab', () => {
createTemporaryDirectory: jest.fn(),
};
const { mockGitlabClient } = require('@gitbeaker/node');
beforeEach(() => {
jest.resetAllMocks();
});