Skip to content

Commit

Permalink
improve names
Browse files Browse the repository at this point in the history
  • Loading branch information
mshustov committed Jan 31, 2020
1 parent e6bbae4 commit bae5b6f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions src/core/server/legacy/integration_tests/logging.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import * as kbnTestServer from '../../../../test_utils/kbn_server';

import {
getPlatformLoggingFromMock,
getLegacyPlatformLoggingFromMock,
getPlatformLogsFromMock,
getLegacyPlatformLogsFromMock,
} from '../../logging/integration_tests/utils';

import { LegacyLoggingConfig } from '../config/legacy_object_to_config_adapter';
Expand Down Expand Up @@ -93,7 +93,7 @@ describe('logging service', () => {
root.logger.get('test-file').info('handled by NP');

expect(mockConsoleLog).toHaveBeenCalledTimes(1);
const loggedString = getPlatformLoggingFromMock(mockConsoleLog);
const loggedString = getPlatformLogsFromMock(mockConsoleLog);
expect(loggedString).toMatchInlineSnapshot(`
Array [
"[xxxx-xx-xxTxx:xx:xx.xxxZ][INFO ][test-file] handled by NP",
Expand All @@ -106,7 +106,7 @@ describe('logging service', () => {

expect(mockStdout).toHaveBeenCalledTimes(1);

const loggedString = getLegacyPlatformLoggingFromMock(mockStdout);
const loggedString = getLegacyPlatformLogsFromMock(mockStdout);
expect(loggedString).toMatchInlineSnapshot(`
Array [
" log [xx:xx:xx.xxx] [info][test-file-legacy] handled by LP
Expand Down Expand Up @@ -138,7 +138,7 @@ describe('logging service', () => {

expect(mockConsoleLog).toHaveBeenCalledTimes(3);

expect(getPlatformLoggingFromMock(mockConsoleLog)).toMatchInlineSnapshot(`
expect(getPlatformLogsFromMock(mockConsoleLog)).toMatchInlineSnapshot(`
Array [
"[xxxx-xx-xxTxx:xx:xx.xxxZ][INFO ][test-file] info",
"[xxxx-xx-xxTxx:xx:xx.xxxZ][WARN ][test-file] warn",
Expand Down Expand Up @@ -169,7 +169,7 @@ describe('logging service', () => {

expect(mockConsoleLog).toHaveBeenCalledTimes(3);

expect(getPlatformLoggingFromMock(mockConsoleLog)).toMatchInlineSnapshot(`
expect(getPlatformLogsFromMock(mockConsoleLog)).toMatchInlineSnapshot(`
Array [
"[xxxx-xx-xxTxx:xx:xx.xxxZ][INFO ][test-file] info",
"[xxxx-xx-xxTxx:xx:xx.xxxZ][WARN ][test-file] warn",
Expand All @@ -185,7 +185,7 @@ describe('logging service', () => {
legacyPlatformLogger.error('error');

expect(mockStdout).toHaveBeenCalledTimes(1);
expect(getLegacyPlatformLoggingFromMock(mockStdout)).toMatchInlineSnapshot(`
expect(getLegacyPlatformLogsFromMock(mockStdout)).toMatchInlineSnapshot(`
Array [
" log [xx:xx:xx.xxx] [error][test-file-legacy] error
",
Expand All @@ -206,7 +206,7 @@ describe('logging service', () => {

expect(mockConsoleLog).toHaveBeenCalledTimes(3);

expect(getPlatformLoggingFromMock(mockConsoleLog)).toMatchInlineSnapshot(`
expect(getPlatformLogsFromMock(mockConsoleLog)).toMatchInlineSnapshot(`
Array [
"[xxxx-xx-xxTxx:xx:xx.xxxZ][INFO ][test-file] info",
"[xxxx-xx-xxTxx:xx:xx.xxxZ][WARN ][test-file] warn",
Expand All @@ -222,7 +222,7 @@ describe('logging service', () => {
legacyPlatformLogger.error('error');

expect(mockStdout).toHaveBeenCalledTimes(3);
expect(getLegacyPlatformLoggingFromMock(mockStdout)).toMatchInlineSnapshot(`
expect(getLegacyPlatformLogsFromMock(mockStdout)).toMatchInlineSnapshot(`
Array [
" log [xx:xx:xx.xxx] [info][test-file-legacy] info
",
Expand Down
8 changes: 4 additions & 4 deletions src/core/server/logging/integration_tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,26 @@ function normalizeLegacyPlatformLogging(input: string) {
return replaceTimestamp(stripColors(input));
}

export function getPlatformLoggingFromMock(logMock: jest.SpyInstance<string, string[]>) {
export function getPlatformLogsFromMock(logMock: jest.SpyInstance<string, string[]>) {
return logMock.mock.calls.map(([message]) => message).map(normalizePlatformLogging);
}

export function getLegacyPlatformLoggingFromMock(stdoutMock: jest.SpyInstance<string, Buffer[]>) {
export function getLegacyPlatformLogsFromMock(stdoutMock: jest.SpyInstance<string, Buffer[]>) {
return stdoutMock.mock.calls
.map(([message]) => message)
.map(String)
.map(normalizeLegacyPlatformLogging);
}

export async function getPlatformLoggingContent(path: string) {
export async function getPlatformLogsFromFile(path: string) {
const fileContent = await readFile(path, 'utf-8');
return fileContent
.split('\n')
.map(s => normalizePlatformLogging(s))
.join('\n');
}

export async function getLegacyPlatformLoggingContent(path: string) {
export async function getLegacyPlatformLogsFromFile(path: string) {
const fileContent = await readFile(path, 'utf-8');
return fileContent
.split('\n')
Expand Down

0 comments on commit bae5b6f

Please sign in to comment.