Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
135 lines
3.1 KiB
TypeScript
135 lines
3.1 KiB
TypeScript
import { mockDeep } from 'jest-mock-extended';
|
|
import type { ConfigListSummary } from 'simple-git';
|
|
|
|
import { mapGitConfigList } from '../GenericFunctions';
|
|
|
|
describe('GenericFunctions', () => {
|
|
describe('mapGitConfigList', () => {
|
|
it('should map the git config list', () => {
|
|
const config = mockDeep<ConfigListSummary>({
|
|
values: {
|
|
'.git/config': {
|
|
'user.name': 'test',
|
|
'core.autocrlf': 'true',
|
|
'remote.origin.url': undefined,
|
|
'remote.origin.pushurl': undefined,
|
|
},
|
|
'/other/config': {
|
|
'user.name': 'other',
|
|
'core.autocrlf': 'false',
|
|
'remote.origin.url': undefined,
|
|
'remote.origin.pushurl': undefined,
|
|
},
|
|
},
|
|
});
|
|
|
|
const result = mapGitConfigList(config);
|
|
|
|
expect(result).toEqual([
|
|
{
|
|
_file: '.git/config',
|
|
'user.name': 'test',
|
|
'core.autocrlf': 'true',
|
|
},
|
|
{
|
|
_file: '/other/config',
|
|
'user.name': 'other',
|
|
'core.autocrlf': 'false',
|
|
},
|
|
]);
|
|
});
|
|
|
|
it('should sanitize the remote origin url', () => {
|
|
const config = mockDeep<ConfigListSummary>({
|
|
values: {
|
|
'.git/config': {
|
|
'remote.origin.url': 'https://user:password@github.com/test/test.git',
|
|
'remote.origin.pushurl': undefined,
|
|
},
|
|
},
|
|
});
|
|
|
|
const result = mapGitConfigList(config);
|
|
|
|
expect(result).toEqual([
|
|
{
|
|
_file: '.git/config',
|
|
'remote.origin.url': 'https://github.com/test/test.git',
|
|
},
|
|
]);
|
|
});
|
|
|
|
it('should sanitize the remote origin urls', () => {
|
|
const config = mockDeep<ConfigListSummary>({
|
|
values: {
|
|
'.git/config': {
|
|
'remote.origin.url': [
|
|
'https://user:password@github.com/test/test.git',
|
|
'https://user:password@github.com/test/other.git',
|
|
],
|
|
'remote.origin.pushurl': undefined,
|
|
},
|
|
},
|
|
});
|
|
|
|
const result = mapGitConfigList(config);
|
|
|
|
expect(result).toEqual([
|
|
{
|
|
_file: '.git/config',
|
|
'remote.origin.url': [
|
|
'https://github.com/test/test.git',
|
|
'https://github.com/test/other.git',
|
|
],
|
|
},
|
|
]);
|
|
});
|
|
|
|
it('should sanitize the remote origin push url', () => {
|
|
const config = mockDeep<ConfigListSummary>({
|
|
values: {
|
|
'.git/config': {
|
|
'remote.origin.pushurl': 'https://user:password@github.com/test/test.git',
|
|
'remote.origin.url': undefined,
|
|
},
|
|
},
|
|
});
|
|
|
|
const result = mapGitConfigList(config);
|
|
|
|
expect(result).toEqual([
|
|
{
|
|
_file: '.git/config',
|
|
'remote.origin.pushurl': 'https://github.com/test/test.git',
|
|
},
|
|
]);
|
|
});
|
|
|
|
it('should sanitize the remote origin push urls', () => {
|
|
const config = mockDeep<ConfigListSummary>({
|
|
values: {
|
|
'.git/config': {
|
|
'remote.origin.pushurl': [
|
|
'https://user:password@github.com/test/test.git',
|
|
'https://user:password@github.com/test/other.git',
|
|
],
|
|
'remote.origin.url': undefined,
|
|
},
|
|
},
|
|
});
|
|
|
|
const result = mapGitConfigList(config);
|
|
|
|
expect(result).toEqual([
|
|
{
|
|
_file: '.git/config',
|
|
'remote.origin.pushurl': [
|
|
'https://github.com/test/test.git',
|
|
'https://github.com/test/other.git',
|
|
],
|
|
},
|
|
]);
|
|
});
|
|
});
|
|
});
|