Skip to content

Commit 5fa3aee

Browse files
mock github link
1 parent 66a9579 commit 5fa3aee

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

redisinsight/api/src/common/validators/github-link.validator.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,10 @@ import {
22
ValidatorConstraint,
33
ValidatorConstraintInterface,
44
} from 'class-validator';
5-
import config from 'src/utils/config';
6-
7-
const SERVER_CONFIG = config.get('server');
85

96
@ValidatorConstraint({ name: 'GitHubLink', async: false })
107
export class GitHubLink implements ValidatorConstraintInterface {
118
validate(value: any) {
12-
// TODO: temporary solution for integration tests
13-
if (SERVER_CONFIG.env === 'test') return true;
14-
159
// Regular expression to match any GitHub URL
1610
const githubUrlRegex = /^https:\/\/github\.com(?:\/[^\s/]+(?:\/[^\s/]+)*)?\/?$/;
1711
return typeof value === 'string' && githubUrlRegex.test(value);

redisinsight/api/test/api/custom-tutorials/POST-custom-tutorials.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ import {
99
path,
1010
serverConfig, requirements,
1111
before,
12+
nock,
1213
_,
1314
} from '../deps';
14-
import { getBaseURL } from '../../helpers/server';
15+
import * as fs from 'fs-extra'
1516
const { server, request, localDb } = deps;
1617

1718
// create endpoint
@@ -107,12 +108,17 @@ const globalManifest = {
107108
children: [],
108109
};
109110

111+
const nockScope = nock('https://github.com/somerepo');
112+
110113
describe('POST /custom-tutorials', () => {
111114
requirements('rte.serverType=local');
112115

113116
before(async () => {
114117
await fsExtra.remove(customTutorialsFolder);
115118
await (await localDb.getRepository(localDb.repositories.CUSTOM_TUTORIAL)).clear();
119+
120+
const zip = fs.readFileSync(path.join(staticsFolder, 'test.zip'))
121+
nockScope.get('/test.zip').reply(200, zip);
116122
});
117123

118124
describe('Common', () => {
@@ -197,7 +203,7 @@ describe('POST /custom-tutorials', () => {
197203

198204
it('should import tutorial from the external link with manifest', async () => {
199205
const zip = new AdmZip(path.join(staticsFolder, 'test.zip'));
200-
const link = `${getBaseURL()}/static/test.zip`;
206+
const link = `https://github.com/somerepo/test.zip`;
201207

202208
await validateApiCall({
203209
endpoint: creatEndpoint,

0 commit comments

Comments
 (0)