Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backport: set up Git remotes from factory url (#691) #697

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
],
"npmClient": "yarn",
"stream": true,
"version": "7.58.0-next",
"version": "7.58.1-next",
"useWorkspaces": true
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eclipse-che/dashboard",
"version": "7.58.0-next",
"version": "7.58.1-next",
"description": "Dashboard for Eclipse Che",
"private": true,
"workspaces": [
Expand Down
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eclipse-che/common",
"version": "7.58.0-next",
"version": "7.58.1-next",
"repository": "https://github.com/eclipse-che/che-dashboard",
"license": "EPL-2.0",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/dashboard-backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eclipse-che/dashboard-backend",
"version": "7.58.0-next",
"version": "7.58.1-next",
"description": "Dashboard backend for Eclipse Che",
"scripts": {
"build": "webpack --color --config webpack.config.prod.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/dashboard-frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eclipse-che/dashboard-frontend",
"version": "7.58.0-next",
"version": "7.58.1-next",
"description": "Dashboard frontend for Eclipse Che",
"private": true,
"repository": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/*
* Copyright (c) 2018-2021 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/

import { getGitRemotes, GitRemote, sanitizeValue } from '../getGitRemotes';

describe('getGitRemotes functions', () => {
describe('getGitRemotes()', () => {
it('should return remotes when one remote is provided', () => {
const input = '{https://github.com/test1/che-dashboard}';
const expected: GitRemote[] = [
{ name: 'origin', url: 'https://github.com/test1/che-dashboard' },
];
expect(getGitRemotes(input)).toMatchObject(expected);
});
it('should return remotes when two remotes are provided', () => {
const input =
'{https://github.com/test1/che-dashboard, https://github.com/test2/che-dashboard}';
const expected: GitRemote[] = [
{ name: 'origin', url: 'https://github.com/test1/che-dashboard' },
{ name: 'upstream', url: 'https://github.com/test2/che-dashboard' },
];
expect(getGitRemotes(input)).toMatchObject(expected);
});

it('should return remotes when three remotes are provided', () => {
const input =
'{https://github.com/test1/che-dashboard, https://github.com/test2/che-dashboard, https://github.com/test3/che-dashboard}';
const expected: GitRemote[] = [
{ name: 'origin', url: 'https://github.com/test1/che-dashboard' },
{ name: 'upstream', url: 'https://github.com/test2/che-dashboard' },
{ name: 'fork1', url: 'https://github.com/test3/che-dashboard' },
];
expect(getGitRemotes(input)).toMatchObject(expected);
});

it('should return remotes when two remotes with names are provided', () => {
const input =
'{{test1,https://github.com/test1/che-dashboard},{test2,https://github.com/test2/che-dashboard}}';
const expected: GitRemote[] = [
{ name: 'test1', url: 'https://github.com/test1/che-dashboard' },
{ name: 'test2', url: 'https://github.com/test2/che-dashboard' },
];
expect(getGitRemotes(input)).toMatchObject(expected);
});

it('should return remotes when one remote with name is provided', () => {
const input = '{{test1,https://github.com/test1/che-dashboard}}';
const expected: GitRemote[] = [
{ name: 'test1', url: 'https://github.com/test1/che-dashboard' },
];
expect(getGitRemotes(input)).toMatchObject(expected);
});

it('should return remotes when multiple remotes with names are provided', () => {
const input =
'{{test1,https://github.com/test1/che-dashboard},{test2,https://github.com/test2/che-dashboard},{test3,https://github.com/test3/che-dashboard},{test4,https://github.com/test4/che-dashboard}}';
const expected: GitRemote[] = [
{ name: 'test1', url: 'https://github.com/test1/che-dashboard' },
{ name: 'test2', url: 'https://github.com/test2/che-dashboard' },
{ name: 'test3', url: 'https://github.com/test3/che-dashboard' },
{ name: 'test4', url: 'https://github.com/test4/che-dashboard' },
];
expect(getGitRemotes(input)).toMatchObject(expected);
});

it('should throw error when cannot parse remotes input', () => {
const input =
'{{https://github.com/test1/che-dashboard,https://github.com/test2/che-dashboard}';
expect(() => {
getGitRemotes(input);
}).toThrow();
});
});

describe('sanitizeValue()', () => {
it('should remove all whitespaces', () => {
const input =
'[ https://github.com/test1/che-dashboard, https://github.com/test2/che-dashboard ] ';
const expected =
'["https://github.com/test1/che-dashboard","https://github.com/test2/che-dashboard"]';
expect(sanitizeValue(input)).toBe(expected);
});
it('should convert left braces', () => {
const input =
'{{test,https://github.com/test1/che-dashboard],{test2,https://github.com/test2/che-dashboard]]';
const expected =
'[["test","https://github.com/test1/che-dashboard"],["test2","https://github.com/test2/che-dashboard"]]';
expect(sanitizeValue(input)).toBe(expected);
});
it('should convert right braces', () => {
const input =
'[[test,https://github.com/test1/che-dashboard},[test2,https://github.com/test2/che-dashboard}}';
const expected =
'[["test","https://github.com/test1/che-dashboard"],["test2","https://github.com/test2/che-dashboard"]]';
expect(sanitizeValue(input)).toBe(expected);
});
it('should add quotations beside left square brackets', () => {
const input =
'[[test","https://github.com/test1/che-dashboard"],[test2","https://github.com/test2/che-dashboard"]]';
const expected =
'[["test","https://github.com/test1/che-dashboard"],["test2","https://github.com/test2/che-dashboard"]]';
expect(sanitizeValue(input)).toBe(expected);
});
it('should add quotations beside right square brackets', () => {
const input =
'[["test","https://github.com/test1/che-dashboard],["test2","https://github.com/test2/che-dashboard]]';
const expected =
'[["test","https://github.com/test1/che-dashboard"],["test2","https://github.com/test2/che-dashboard"]]';
expect(sanitizeValue(input)).toBe(expected);
});
it('should add quotations when in between two strings', () => {
const input =
'[["test,https://github.com/test1/che-dashboard"],["test2,https://github.com/test2/che-dashboard"]]';
const expected =
'[["test","https://github.com/test1/che-dashboard"],["test2","https://github.com/test2/che-dashboard"]]';
expect(sanitizeValue(input)).toBe(expected);
});
});
});
Loading