diff --git a/test/config/CommandLine.ts b/test/config/CommandLine.ts index cf5fcf2..fd4591f 100644 --- a/test/config/CommandLine.ts +++ b/test/config/CommandLine.ts @@ -19,23 +19,6 @@ export interface CommandLineOptions { browserstackKey: string; } -interface ConfigurationObject { - viewers: string[]; - publishers: string[]; - tests: string[]; - useBrowserstack: boolean; - useBrowserstackLocal: boolean; - browserstackUser: string; - browserstackKey: string; - logLevel: LoggingLevel; - applicationId: string; - secret: string; - pcastUri: string; - ingestUri: string; - channelUri: string; - publisherUri?: string; -} - const defaultLogLevel = LoggingLevel.Info; const defaultViewers: string[] = []; const defaultPublishers: string[] = []; @@ -55,7 +38,7 @@ export default class CommandLine { /** * Converts a configuration object to command line arguments array */ - public static configToArgs(config: ConfigurationObject): string[] { + public static configToArgs(config: CommandLineOptions): string[] { const args: string[] = []; // Required options @@ -109,34 +92,35 @@ export default class CommandLine { static { CommandLine._program.version(PackageJson.version); - CommandLine._setupProgramOptions(); - } - - private static _setupProgramOptions(): void { - const handleArrayOption = (value: string, previousValue: string[]) => { - if (previousValue) { - return previousValue.concat(value); - } - - return [value]; - }; - // Required options - CommandLine._program.requiredOption('--application-id ', 'The application ID to use'); - CommandLine._program.requiredOption('--secret ', 'The secret to use'); - CommandLine._program.requiredOption('--pcast-uri ', 'The pcast URI to use'); - CommandLine._program.requiredOption('--channel-uri ', 'The channel URI to use'); + const setupProgramOptions = (): void => { + const handleArrayOption = (value: string, previousValue: string[]) => { + if (previousValue) { + return previousValue.concat(value); + } + + return [value]; + }; + + // Required options + CommandLine._program.requiredOption('--application-id ', 'The application ID to use'); + CommandLine._program.requiredOption('--secret ', 'The secret to use'); + CommandLine._program.requiredOption('--pcast-uri ', 'The pcast URI to use'); + CommandLine._program.requiredOption('--channel-uri ', 'The channel URI to use'); + + CommandLine._program.option('--ingest-uri ', 'The ingest URI to use'); + CommandLine._program.option('--publisher-uri ', 'The publisher URI to use'); + CommandLine._program.option('--viewer ', 'The browser and OS for simulating a viewer to use', handleArrayOption, defaultViewers); + CommandLine._program.option('--publisher ', 'The browser and OS for simulating a publisher to use', handleArrayOption, defaultPublishers); + CommandLine._program.option('-t, --test ', 'The test to run', handleArrayOption, defaultTests); + CommandLine._program.option('--use-browserstack', 'Run tests using BrowserStack', defaultUseBrowserstack); + CommandLine._program.option('--use-browserstack-local', 'Run tests using BrowserStack Local', defaultUseBrowserstackLocal); + CommandLine._program.option('--browserstack-user ', 'The BrowserStack username to use', process.env.BROWSERSTACK_USER || ''); + CommandLine._program.option('--browserstack-key ', 'The BrowserStack key to use', process.env.BROWSERSTACK_KEY || ''); + CommandLine._program.option('--log-level ', 'The log level to use', LoggingLevelMapping.convertLoggingLevelToLoggingLevelType(defaultLogLevel)); + } - CommandLine._program.option('--ingest-uri ', 'The ingest URI to use'); - CommandLine._program.option('--publisher-uri ', 'The publisher URI to use'); - CommandLine._program.option('--viewer ', 'The browser and OS for simulating a viewer to use', handleArrayOption, defaultViewers); - CommandLine._program.option('--publisher ', 'The browser and OS for simulating a publisher to use', handleArrayOption, defaultPublishers); - CommandLine._program.option('-t, --test ', 'The test to run', handleArrayOption, defaultTests); - CommandLine._program.option('--use-browserstack', 'Run tests using BrowserStack', defaultUseBrowserstack); - CommandLine._program.option('--use-browserstack-local', 'Run tests using BrowserStack Local', defaultUseBrowserstackLocal); - CommandLine._program.option('--browserstack-user ', 'The BrowserStack username to use', process.env.BROWSERSTACK_USER || ''); - CommandLine._program.option('--browserstack-key ', 'The BrowserStack key to use', process.env.BROWSERSTACK_KEY || ''); - CommandLine._program.option('--log-level ', 'The log level to use', LoggingLevelMapping.convertLoggingLevelToLoggingLevelType(defaultLogLevel)); + setupProgramOptions(); } private constructor() { diff --git a/test/logger/LoggerFactory.ts b/test/logger/LoggerFactory.ts index 6006013..fbdc1d7 100644 --- a/test/logger/LoggerFactory.ts +++ b/test/logger/LoggerFactory.ts @@ -21,10 +21,9 @@ export default class LoggerFactory { return logger; } - public static setLoggingLevel(level: LoggingLevelType): void { - const loggingLevel = LoggingLevelMapping.convertLoggingLevelTypeToLoggingLevel(level); - console.log(`${new Date().toISOString()} [LoggerFactory] Setting logging level to [${level}]`); - LoggerFactory._threshold.level = loggingLevel; + public static setLoggingLevel(level: LoggingLevel): void { + console.log(`${new Date().toISOString()} [LoggerFactory] Setting logging level to [${LoggingLevelMapping.convertLoggingLevelToLoggingLevelType(level)}]`); + LoggerFactory._threshold.level = level; } private constructor() {