mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-01-27 22:59:51 -05:00
test: relocate unit test cli, proxy, utils
This commit is contained in:
parent
ca2e23cf9d
commit
b1eb7c6278
7 changed files with 45 additions and 36 deletions
|
@ -1,14 +1,14 @@
|
|||
import path from 'path';
|
||||
import _ from 'lodash';
|
||||
|
||||
import startServer from '../../../src/index';
|
||||
import config from '../partials/config/index';
|
||||
import {DEFAULT_DOMAIN, DEFAULT_PORT, DEFAULT_PROTOCOL} from '../../../src/lib/constants';
|
||||
import {getListListenAddresses} from '../../../src/lib/cli/utils';
|
||||
import startServer from '../../../../src';
|
||||
import config from '../../partials/config';
|
||||
import {DEFAULT_DOMAIN, DEFAULT_PORT, DEFAULT_PROTOCOL} from '../../../../src/lib/constants';
|
||||
import {getListListenAddresses} from '../../../../src/lib/cli/utils';
|
||||
|
||||
const logger = require('../../../src/lib/logger');
|
||||
const logger = require('../../../../src/lib/logger');
|
||||
|
||||
jest.mock('../../../src/lib/logger', () => ({
|
||||
jest.mock('../../../../src/lib/logger', () => ({
|
||||
setup: jest.fn(),
|
||||
logger: {
|
||||
child: jest.fn(),
|
|
@ -1,12 +1,12 @@
|
|||
import path from 'path';
|
||||
import _ from 'lodash';
|
||||
|
||||
import Config from '../../../src/lib/config';
|
||||
import {parseConfigFile} from '../../../src/lib/utils';
|
||||
import {DEFAULT_REGISTRY, DEFAULT_UPLINK, ROLES, WEB_TITLE} from '../../../src/lib/constants';
|
||||
import Config from '../../../../src/lib/config';
|
||||
import {parseConfigFile} from '../../../../src/lib/utils';
|
||||
import {DEFAULT_REGISTRY, DEFAULT_UPLINK, ROLES, WEB_TITLE} from '../../../../src/lib/constants';
|
||||
|
||||
const resolveConf = (conf) => path.join(__dirname, `../../../conf/${conf}.yaml`);
|
||||
require('../../../src/lib/logger').setup([]);
|
||||
const resolveConf = (conf) => path.join(__dirname, `../../../../conf/${conf}.yaml`);
|
||||
require('../../../../src/lib/logger').setup([]);
|
||||
|
||||
const checkDefaultUplink = (config) => {
|
||||
expect(_.isObject(config.uplinks[DEFAULT_UPLINK])).toBeTruthy();
|
|
@ -3,20 +3,20 @@
|
|||
import rimRaf from 'rimraf';
|
||||
import path from 'path';
|
||||
|
||||
import LocalStorage from '../../../src/lib/local-storage';
|
||||
import AppConfig from '../../../src/lib/config';
|
||||
import LocalStorage from '../../../../src/lib/local-storage';
|
||||
import AppConfig from '../../../../src/lib/config';
|
||||
// $FlowFixMe
|
||||
import configExample from '../partials/config/index';
|
||||
import Logger, {setup} from '../../../src/lib/logger';
|
||||
import {readFile} from '../../functional/lib/test.utils';
|
||||
import {generatePackageTemplate} from '../../../src/lib/storage-utils';
|
||||
import {generateNewVersion} from '../../lib/utils-test';
|
||||
import configExample from '../../partials/config';
|
||||
import Logger, {setup} from '../../../../src/lib/logger';
|
||||
import {readFile} from '../../../functional/lib/test.utils';
|
||||
import {generatePackageTemplate} from '../../../../src/lib/storage-utils';
|
||||
import {generateNewVersion} from '../../../lib/utils-test';
|
||||
|
||||
const readMetadata = (fileName: string = 'metadata') => readFile(`../../unit/partials/${fileName}`);
|
||||
|
||||
import type {Config, MergeTags} from '@verdaccio/types';
|
||||
import type {IStorage} from '../../../types/index';
|
||||
import { API_ERROR, HTTP_STATUS, DIST_TAGS} from '../../../src/lib/constants';
|
||||
import type {IStorage} from '../../../../types';
|
||||
import { API_ERROR, HTTP_STATUS, DIST_TAGS} from '../../../../src/lib/constants';
|
||||
|
||||
setup([]);
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
// @flow
|
||||
|
||||
import {normalizePackage, mergeUplinkTimeIntoLocal} from "../../../src/lib/storage-utils";
|
||||
import { STORAGE, DIST_TAGS } from '../../../src/lib/constants';
|
||||
import {readFile} from "../../functional/lib/test.utils";
|
||||
import {normalizePackage, mergeUplinkTimeIntoLocal} from "../../../../src/lib/storage-utils";
|
||||
import { STORAGE, DIST_TAGS } from '../../../../src/lib/constants';
|
||||
import {readFile} from "../../../functional/lib/test.utils";
|
||||
|
||||
import type {Package} from '@verdaccio/types';
|
||||
|
|
@ -1,15 +1,17 @@
|
|||
import Storage from '../../../src/lib/up-storage';
|
||||
import Storage from '../../../../src/lib/up-storage';
|
||||
|
||||
require('../../../src/lib/logger').setup([]);
|
||||
require('../../../../src/lib/logger').setup([]);
|
||||
|
||||
function setupProxy(host, config, mainconfig) {
|
||||
function setupProxy(host, config, mainConfig) {
|
||||
config.url = host;
|
||||
return new Storage(config, mainconfig);
|
||||
|
||||
return new Storage(config, mainConfig);
|
||||
}
|
||||
|
||||
describe('Use proxy', () => {
|
||||
test('should work fine without proxy', () => {
|
||||
let x = setupProxy('http://x/x', {}, {});
|
||||
|
||||
expect(x.proxy).toEqual(undefined);
|
||||
});
|
||||
|
||||
|
@ -20,6 +22,7 @@ describe('Use proxy', () => {
|
|||
|
||||
test('no_proxy is invalid', () => {
|
||||
let x = setupProxy('http://x/x', {http_proxy: '123', no_proxy: false}, {});
|
||||
|
||||
expect(x.proxy).toEqual('123');
|
||||
x = setupProxy('http://x/x', {http_proxy: '123', no_proxy: null}, {});
|
||||
expect(x.proxy).toEqual('123');
|
||||
|
@ -31,16 +34,19 @@ describe('Use proxy', () => {
|
|||
|
||||
test('no_proxy - simple/include', () => {
|
||||
let x = setupProxy('http://localhost', {http_proxy: '123'}, {no_proxy: 'localhost'});
|
||||
|
||||
expect(x.proxy).toEqual(undefined);
|
||||
});
|
||||
|
||||
test('no_proxy - simple/not', () => {
|
||||
let x = setupProxy('http://localhost', {http_proxy: '123'}, {no_proxy: 'blah'});
|
||||
|
||||
expect(x.proxy).toEqual('123');
|
||||
});
|
||||
|
||||
test('no_proxy - various, single string', () => {
|
||||
let x = setupProxy('http://blahblah', {http_proxy: '123'}, {no_proxy: 'blah'});
|
||||
|
||||
expect(x.proxy).toEqual('123');
|
||||
x = setupProxy('http://blah.blah', {}, {http_proxy: '123', no_proxy: 'blah'});
|
||||
expect(x.proxy).toEqual(undefined);
|
||||
|
@ -56,6 +62,7 @@ describe('Use proxy', () => {
|
|||
|
||||
test('no_proxy - various, array', () => {
|
||||
let x = setupProxy('http://blahblah', {http_proxy: '123'}, {no_proxy: 'foo,bar,blah'});
|
||||
|
||||
expect(x.proxy).toEqual('123');
|
||||
x = setupProxy('http://blah.blah', {http_proxy: '123'}, {no_proxy: 'foo,bar,blah'});
|
||||
expect(x.proxy).toEqual(undefined);
|
||||
|
@ -71,6 +78,7 @@ describe('Use proxy', () => {
|
|||
|
||||
test('no_proxy - hostport', () => {
|
||||
let x = setupProxy('http://localhost:80', {http_proxy: '123'}, {no_proxy: 'localhost'});
|
||||
|
||||
expect(x.proxy).toEqual(undefined);
|
||||
x = setupProxy('http://localhost:8080', {http_proxy: '123'}, {no_proxy: 'localhost'});
|
||||
expect(x.proxy).toEqual(undefined);
|
||||
|
@ -78,6 +86,7 @@ describe('Use proxy', () => {
|
|||
|
||||
test('no_proxy - secure', () => {
|
||||
let x = setupProxy('https://something', {http_proxy: '123'}, {});
|
||||
|
||||
expect(x.proxy).toEqual(undefined);
|
||||
x = setupProxy('https://something', {https_proxy: '123'}, {});
|
||||
expect(x.proxy).toEqual('123');
|
|
@ -1,16 +1,16 @@
|
|||
// @flow
|
||||
import _ from 'lodash';
|
||||
import ProxyStorage from '../../../src/lib/up-storage';
|
||||
import AppConfig from '../../../src/lib/config';
|
||||
import ProxyStorage from '../../../../src/lib/up-storage';
|
||||
import AppConfig from '../../../../src/lib/config';
|
||||
// $FlowFixMe
|
||||
import configExample from '../partials/config/index';
|
||||
import {setup} from '../../../src/lib/logger';
|
||||
import configExample from '../../partials/config';
|
||||
import {setup} from '../../../../src/lib/logger';
|
||||
|
||||
import type {Config, UpLinkConf} from '@verdaccio/types';
|
||||
import type {IProxy} from '../../../types/index';
|
||||
import {API_ERROR, HTTP_STATUS} from "../../../src/lib/constants";
|
||||
import {mockServer} from '../__helper/mock';
|
||||
import {DOMAIN_SERVERS} from '../../functional/config.functional';
|
||||
import type {IProxy} from '../../../../types';
|
||||
import {API_ERROR, HTTP_STATUS} from "../../../../src/lib/constants";
|
||||
import {mockServer} from '../../__helper/mock';
|
||||
import {DOMAIN_SERVERS} from '../../../functional/config.functional';
|
||||
|
||||
setup([]);
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
let assert = require('assert');
|
||||
let parseInterval = require('../../../src/lib/utils').parseInterval;
|
||||
let parseInterval = require('../../../../src/lib/utils').parseInterval;
|
||||
|
||||
describe('Parse interval', () => {
|
||||
function add_test(str, res) {
|
Loading…
Add table
Reference in a new issue