1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-02-21 07:29:37 +01:00

refactor: remove usage of assert from cache.js [#973] (#1043)

* refactor: remove usage of assert from cache.js [#973]

* refactor: remove usage of assert from no_proxy.spec.js [#973]

* refactor: remove usage of assert from cache.js [#973]
This commit is contained in:
Andrew Shanks 2018-10-03 22:39:45 +01:00 committed by Juan Picado @jotadeveloper
parent 83b586f000
commit 9ed8f3497c
2 changed files with 29 additions and 30 deletions

@ -1,6 +1,6 @@
import fs from 'fs';
import path from 'path';
import assert from 'assert';
import crypto from 'crypto';
import {readFile} from '../lib/test.utils';
import {HTTP_STATUS} from "../../../src/lib/constants";
import {TARBALL} from '../config.functional';
@ -35,7 +35,7 @@ export default function (server, server2, server3) {
beforeAll(function () {
const pkg = require('../fixtures/package')(PKG_GH131);
pkg.dist.shasum = createTarballHash().update(getBinary()).digest('hex');
pkg.dist.shasum = crypto.createHash('sha1').update(getBinary()).digest('hex');
return server.putVersion(PKG_GH131, '0.0.1', pkg)
.status(HTTP_STATUS.CREATED)
@ -52,7 +52,7 @@ export default function (server, server2, server3) {
});
test('should be caching packages from uplink server1', () => {
assert.equal(isCached(PKG_GH131, TARBALL), true);
expect(isCached(PKG_GH131, TARBALL)).toEqual(true);
});
beforeAll(function () {
@ -85,7 +85,7 @@ export default function (server, server2, server3) {
});
test('must not be caching packages from uplink server2', () => {
assert.equal(isCached(PKG_GH1312, TARBALL), false);
expect(isCached(PKG_GH1312, TARBALL)).toEqual(false);
});
});

@ -1,4 +1,3 @@
import assert from 'assert';
import Storage from '../../../src/lib/up-storage';
require('../../../src/lib/logger').setup([]);
@ -11,78 +10,78 @@ function setupProxy(host, config, mainconfig) {
describe('Use proxy', () => {
test('should work fine without proxy', () => {
let x = setupProxy('http://x/x', {}, {});
assert.equal(x.proxy, null);
expect(x.proxy).toEqual(undefined);
});
test('local config should take priority', () => {
let x = setupProxy('http://x/x', {http_proxy: '123'}, {http_proxy: '456'});
assert.equal(x.proxy, '123');
expect(x.proxy).toEqual('123');
});
test('no_proxy is invalid', () => {
let x = setupProxy('http://x/x', {http_proxy: '123', no_proxy: false}, {});
assert.equal(x.proxy, '123');
expect(x.proxy).toEqual('123');
x = setupProxy('http://x/x', {http_proxy: '123', no_proxy: null}, {});
assert.equal(x.proxy, '123');
expect(x.proxy).toEqual('123');
x = setupProxy('http://x/x', {http_proxy: '123', no_proxy: []}, {});
assert.equal(x.proxy, '123');
expect(x.proxy).toEqual('123');
x = setupProxy('http://x/x', {http_proxy: '123', no_proxy: ''}, {});
assert.equal(x.proxy, '123');
expect(x.proxy).toEqual('123');
});
test('no_proxy - simple/include', () => {
let x = setupProxy('http://localhost', {http_proxy: '123'}, {no_proxy: 'localhost'});
assert.equal(x.proxy, undefined);
expect(x.proxy).toEqual(undefined);
});
test('no_proxy - simple/not', () => {
let x = setupProxy('http://localhost', {http_proxy: '123'}, {no_proxy: 'blah'});
assert.equal(x.proxy, '123');
expect(x.proxy).toEqual('123');
});
test('no_proxy - various, single string', () => {
let x = setupProxy('http://blahblah', {http_proxy: '123'}, {no_proxy: 'blah'});
assert.equal(x.proxy, '123');
expect(x.proxy).toEqual('123');
x = setupProxy('http://blah.blah', {}, {http_proxy: '123', no_proxy: 'blah'});
assert.equal(x.proxy, null);
expect(x.proxy).toEqual(undefined);
x = setupProxy('http://blahblah', {}, {http_proxy: '123', no_proxy: '.blah'});
assert.equal(x.proxy, '123');
expect(x.proxy).toEqual('123');
x = setupProxy('http://blah.blah', {http_proxy: '123', no_proxy: '.blah'}, {});
assert.equal(x.proxy, null);
expect(x.proxy).toEqual(undefined);
x = setupProxy('http://blah', {http_proxy: '123', no_proxy: '.blah'}, {});
assert.equal(x.proxy, null);
expect(x.proxy).toEqual(undefined);
x = setupProxy('http://blahh', {http_proxy: '123', no_proxy: 'blah'}, {});
assert.equal(x.proxy, '123');
expect(x.proxy).toEqual('123');
});
test('no_proxy - various, array', () => {
let x = setupProxy('http://blahblah', {http_proxy: '123'}, {no_proxy: 'foo,bar,blah'});
assert.equal(x.proxy, '123');
expect(x.proxy).toEqual('123');
x = setupProxy('http://blah.blah', {http_proxy: '123'}, {no_proxy: 'foo,bar,blah'});
assert.equal(x.proxy, null);
expect(x.proxy).toEqual(undefined);
x = setupProxy('http://blah.foo', {http_proxy: '123'}, {no_proxy: 'foo,bar,blah'});
assert.equal(x.proxy, null);
expect(x.proxy).toEqual(undefined);
x = setupProxy('http://foo.baz', {http_proxy: '123'}, {no_proxy: 'foo,bar,blah'});
assert.equal(x.proxy, '123');
expect(x.proxy).toEqual('123');
x = setupProxy('http://blahblah', {http_proxy: '123'}, {no_proxy: ['foo', 'bar', 'blah']});
assert.equal(x.proxy, '123');
expect(x.proxy).toEqual('123');
x = setupProxy('http://blah.blah', {http_proxy: '123'}, {no_proxy: ['foo', 'bar', 'blah']});
assert.equal(x.proxy, null);
expect(x.proxy).toEqual(undefined);
});
test('no_proxy - hostport', () => {
let x = setupProxy('http://localhost:80', {http_proxy: '123'}, {no_proxy: 'localhost'});
assert.equal(x.proxy, null);
expect(x.proxy).toEqual(undefined);
x = setupProxy('http://localhost:8080', {http_proxy: '123'}, {no_proxy: 'localhost'});
assert.equal(x.proxy, null);
expect(x.proxy).toEqual(undefined);
});
test('no_proxy - secure', () => {
let x = setupProxy('https://something', {http_proxy: '123'}, {});
assert.equal(x.proxy, null);
expect(x.proxy).toEqual(undefined);
x = setupProxy('https://something', {https_proxy: '123'}, {});
assert.equal(x.proxy, '123');
expect(x.proxy).toEqual('123');
x = setupProxy('https://something', {http_proxy: '456', https_proxy: '123'}, {});
assert.equal(x.proxy, '123');
expect(x.proxy).toEqual('123');
});
});