Skip to content

Commit

Permalink
Get rid of __tests__ folders in the core. (#22662)
Browse files Browse the repository at this point in the history
  • Loading branch information
azasypkin authored Sep 7, 2018
1 parent 03553de commit bdd1d53
Show file tree
Hide file tree
Showing 82 changed files with 95 additions and 101 deletions.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

// Test helpers to simplify mocking environment options.

import { EnvOptions } from '../../env';
import { EnvOptions } from '../env';

type DeepPartial<T> = {
[P in keyof T]?: T[P] extends Array<infer R> ? Array<DeepPartial<R>> : DeepPartial<T[P]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { Config, ObjectToConfigAdapter } from '..';
import { Config, ObjectToConfigAdapter } from '.';

/**
* Overrides some config values with ones from argv.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ import { BehaviorSubject } from 'rxjs';
import { first } from 'rxjs/operators';

const mockPackage = new Proxy({ raw: {} as any }, { get: (obj, prop) => obj.raw[prop] });
jest.mock('../../../../utils/package_json', () => ({ pkg: mockPackage }));
jest.mock('../../../utils/package_json', () => ({ pkg: mockPackage }));

import { schema, Type, TypeOf } from '../schema';
import { schema, Type, TypeOf } from './schema';

import { ConfigService, ObjectToConfigAdapter } from '..';
import { logger } from '../../logging/__mocks__';
import { Env } from '../env';
import { ConfigService, Env, ObjectToConfigAdapter } from '.';
import { logger } from '../logging/__mocks__';
import { getEnvOptions } from './__mocks__/env';

const emptyArgv = getEnvOptions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { ensureDeepObject } from '../ensure_deep_object';
import { ensureDeepObject } from './ensure_deep_object';

test('flat object', () => {
const obj = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ jest.mock('path', () => ({
}));

const mockPackage = new Proxy({ raw: {} as any }, { get: (obj, prop) => obj.raw[prop] });
jest.mock('../../../../utils/package_json', () => ({ pkg: mockPackage }));
jest.mock('../../../utils/package_json', () => ({ pkg: mockPackage }));

import { Env } from '../env';
import { Env } from '.';
import { getEnvOptions } from './__mocks__/env';

test('correctly creates default environment in dev mode.', () => {
Expand Down
1 change: 0 additions & 1 deletion src/core/server/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ export { Config, ConfigPath } from './config';
export { ObjectToConfigAdapter } from './object_to_config_adapter';
export { Env, CliArgs } from './env';
export { ConfigWithSchema } from './config_with_schema';
export { getConfigFromFiles } from './read_config';
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@

const mockGetConfigFromFiles = jest.fn();

jest.mock('../read_config', () => ({
jest.mock('./read_config', () => ({
getConfigFromFiles: mockGetConfigFromFiles,
}));

import { first } from 'rxjs/operators';
import { RawConfigService } from '../raw_config_service';
import { RawConfigService } from '.';

const configFile = '/config/kibana.yml';
const anotherConfigFile = '/config/kibana.dev.yml';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { relative, resolve } from 'path';
import { getConfigFromFiles } from '../read_config';
import { getConfigFromFiles } from './read_config';

const fixtureFile = (name: string) => `${__dirname}/__fixtures__/${name}`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { ByteSizeValue } from '../';
import { ByteSizeValue } from '.';

describe('parsing units', () => {
test('bytes', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { relative } from 'path';
import { SchemaError } from '..';
import { SchemaError } from '.';

/**
* Make all paths in stacktrace relative.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { schema } from '../..';
import { schema } from '..';

test('works for any value', () => {
expect(schema.any().validate(true)).toBe(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { schema } from '../..';
import { schema } from '..';

test('returns value if it matches the type', () => {
const type = schema.arrayOf(schema.string());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { schema } from '../..';
import { schema } from '..';

test('returns value by default', () => {
expect(schema.boolean().validate(true)).toBe(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
* under the License.
*/

import { schema } from '../..';
import { ByteSizeValue } from '../../byte_size_value';
import { schema } from '..';
import { ByteSizeValue } from '../byte_size_value';

const { byteSize } = schema;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { schema } from '../..';
import { schema } from '..';

test('required by default', () => {
const type = schema.conditional(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { duration as momentDuration } from 'moment';
import { schema } from '../..';
import { schema } from '..';

const { duration } = schema;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { schema } from '../..';
import { schema } from '..';

const { literal } = schema;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { schema } from '../..';
import { schema } from '..';

test('handles object as input', () => {
const type = schema.mapOf(schema.string(), schema.string());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { schema } from '../..';
import { schema } from '..';

test('returns value if specified', () => {
const type = schema.maybe(schema.string());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { schema } from '../..';
import { schema } from '..';

test('returns value by default', () => {
expect(schema.number().validate(4)).toBe(4);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { schema } from '../..';
import { schema } from '..';

test('returns value by default', () => {
const type = schema.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { schema } from '../..';
import { schema } from '..';

test('handles string', () => {
expect(schema.oneOf([schema.string()]).validate('test')).toBe('test');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { schema } from '../..';
import { schema } from '..';

test('returns value is string and defined', () => {
expect(schema.string().validate('test')).toBe('test');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { HttpConfig } from '../http_config';
import { HttpConfig } from '.';

test('has defaults for config', () => {
const httpSchema = HttpConfig.schema;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ jest.mock('fs', () => ({
import Chance from 'chance';
import supertest from 'supertest';

import { ByteSizeValue } from '../../config/schema';
import { logger } from '../../logging/__mocks__';
import { HttpConfig } from '../http_config';
import { HttpServer } from '../http_server';
import { Router } from '../router';
import { HttpConfig, Router } from '.';
import { ByteSizeValue } from '../config/schema';
import { logger } from '../logging/__mocks__';
import { HttpServer } from './http_server';

const chance = new Chance();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,14 @@

const mockHttpServer = jest.fn();

jest.mock('../http_server', () => ({
jest.mock('./http_server', () => ({
HttpServer: mockHttpServer,
}));

import { noop } from 'lodash';
import { BehaviorSubject } from 'rxjs';
import { logger } from '../../logging/__mocks__';
import { HttpConfig } from '../http_config';
import { HttpService } from '../http_service';
import { Router } from '../router';
import { HttpConfig, HttpService, Router } from '.';
import { logger } from '../logging/__mocks__';

beforeEach(() => {
logger.mockClear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import Chance from 'chance';
import { Server } from 'http';
import supertest from 'supertest';

import { ByteSizeValue } from '../../config/schema';
import { logger } from '../../logging/__mocks__';
import { HttpConfig } from '../http_config';
import { HttpsRedirectServer } from '../https_redirect_server';
import { HttpConfig } from '.';
import { ByteSizeValue } from '../config/schema';
import { logger } from '../logging/__mocks__';
import { HttpsRedirectServer } from './https_redirect_server';

const chance = new Chance();

Expand Down
2 changes: 1 addition & 1 deletion src/core/server/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jest.mock('./legacy_compat/legacy_service', () => ({
import { BehaviorSubject } from 'rxjs';
import { Server } from '.';
import { Env } from './config';
import { getEnvOptions } from './config/__tests__/__mocks__/env';
import { getEnvOptions } from './config/__mocks__/env';
import { logger } from './logging/__mocks__';

const mockConfigService = { atPath: jest.fn(), getUnusedPaths: jest.fn().mockReturnValue([]) };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { LegacyObjectToConfigAdapter } from '../legacy_object_to_config_adapter';
import { LegacyObjectToConfigAdapter } from './legacy_object_to_config_adapter';

describe('#get', () => {
test('correctly handles paths that do not exist.', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import { Server } from 'net';

import { LegacyPlatformProxy } from '../legacy_platform_proxy';
import { LegacyPlatformProxy } from './legacy_platform_proxy';

let server: jest.Mocked<Server>;
let proxy: LegacyPlatformProxy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@

import { BehaviorSubject, Subject, throwError } from 'rxjs';

jest.mock('../legacy_platform_proxy');
jest.mock('../../../../server/kbn_server');
jest.mock('../../../../cli/cluster/cluster_manager');
jest.mock('./legacy_platform_proxy');
jest.mock('../../../server/kbn_server');
jest.mock('../../../cli/cluster/cluster_manager');

import { first } from 'rxjs/operators';
import { LegacyService } from '.';
// @ts-ignore: implicit any for JS file
import MockClusterManager from '../../../../cli/cluster/cluster_manager';
import MockClusterManager from '../../../cli/cluster/cluster_manager';
// @ts-ignore: implicit any for JS file
import MockKbnServer from '../../../../server/kbn_server';
import { Config, ConfigService, Env, ObjectToConfigAdapter } from '../../config';
import { getEnvOptions } from '../../config/__tests__/__mocks__/env';
import { logger } from '../../logging/__mocks__';
import { LegacyPlatformProxy } from '../legacy_platform_proxy';
import { LegacyService } from '../legacy_service';
import MockKbnServer from '../../../server/kbn_server';
import { Config, ConfigService, Env, ObjectToConfigAdapter } from '../config';
import { getEnvOptions } from '../config/__mocks__/env';
import { logger } from '../logging/__mocks__';
import { LegacyPlatformProxy } from './legacy_platform_proxy';

const MockLegacyPlatformProxy: jest.Mock<LegacyPlatformProxy> = LegacyPlatformProxy as any;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
* under the License.
*/

jest.mock('../../legacy_logging_server');
jest.mock('../legacy_logging_server');

import { LogLevel } from '../../../../logging/log_level';
import { LogRecord } from '../../../../logging/log_record';
import { LegacyLoggingServer } from '../../legacy_logging_server';
import { LegacyAppender } from '../legacy_appender';
import { LogLevel } from '../../../logging/log_level';
import { LogRecord } from '../../../logging/log_record';
import { LegacyLoggingServer } from '../legacy_logging_server';
import { LegacyAppender } from './legacy_appender';

afterEach(() => (LegacyLoggingServer as any).mockClear());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/

const mockCreateLayout = jest.fn();
jest.mock('../../layouts/layouts', () => {
const { schema } = require('../../../config/schema');
jest.mock('../layouts/layouts', () => {
const { schema } = require('../../config/schema');
return {
Layouts: {
configSchema: schema.object({ kind: schema.literal('mock') }),
Expand All @@ -28,10 +28,10 @@ jest.mock('../../layouts/layouts', () => {
};
});

import { LegacyAppender } from '../../../legacy_compat/logging/appenders/legacy_appender';
import { Appenders } from '../appenders';
import { ConsoleAppender } from '../console/console_appender';
import { FileAppender } from '../file/file_appender';
import { LegacyAppender } from '../../legacy_compat/logging/appenders/legacy_appender';
import { Appenders } from './appenders';
import { ConsoleAppender } from './console/console_appender';
import { FileAppender } from './file/file_appender';

beforeEach(() => {
mockCreateLayout.mockReset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import { LogLevel } from '../../log_level';
import { LogRecord } from '../../log_record';
import { BufferAppender } from '../buffer/buffer_appender';
import { BufferAppender } from './buffer_appender';

test('`flush()` does not return any record buffered at the beginning.', () => {
const appender = new BufferAppender();
Expand Down
Loading

0 comments on commit bdd1d53

Please sign in to comment.