From fbe755750dd5a4f846f0e7e43d03a4f8e14f41a3 Mon Sep 17 00:00:00 2001 From: Pedro Ramos Date: Tue, 28 May 2024 19:27:07 +0200 Subject: [PATCH 1/2] Use a different path for analytics config file --- test/integration/config/analytics.test.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/integration/config/analytics.test.ts b/test/integration/config/analytics.test.ts index 4d95d641e08..f1eadfe0640 100644 --- a/test/integration/config/analytics.test.ts +++ b/test/integration/config/analytics.test.ts @@ -5,7 +5,7 @@ describe('config:analytics', () => { test .stderr() .stdout() - .command(['config:analytics', '--disable']) + .command(['ASYNCAPI_METRICS_CONFIG_PATH=./test/fixtures/.asyncapi-analytics', 'config:analytics', '--disable']) .it('should show a successful message once the analytics are disabled', async (ctx, done) => { expect(ctx.stdout).to.equal('\nAnalytics disabled.\n\n'); expect(ctx.stderr).to.equal(''); @@ -17,7 +17,7 @@ describe('config:analytics', () => { test .stderr() .stdout() - .command(['config:analytics', '--enable']) + .command(['ASYNCAPI_METRICS_CONFIG_PATH=./test/fixtures/.asyncapi-analytics', 'config:analytics', '--enable']) .it('should show a successful message once the analytics are enabled', (ctx, done) => { expect(ctx.stdout).to.equal('\nAnalytics enabled.\n\n'); expect(ctx.stderr).to.equal(''); @@ -29,7 +29,7 @@ describe('config:analytics', () => { test .stderr() .stdout() - .command(['config:analytics']) + .command(['ASYNCAPI_METRICS_CONFIG_PATH=./test/fixtures/.asyncapi-analytics', 'config:analytics']) .it('should show informational message when no flags are used', (ctx, done) => { expect(ctx.stdout).to.equal('\nPlease append the "--disable" flag to the command in case you prefer to disable analytics, or use the "--enable" flag if you want to enable analytics back again. In case you do not know the analytics current status, then you can append the "--status" flag to be aware of it.\n\n'); expect(ctx.stderr).to.equal(''); @@ -41,7 +41,7 @@ describe('config:analytics', () => { test .stderr() .stdout() - .command(['config:analytics', '--status']) + .command(['ASYNCAPI_METRICS_CONFIG_PATH=./test/fixtures/.asyncapi-analytics', 'config:analytics', '--status']) .it('should show a different informational message depending on the analytics status', (ctx, done) => { expect(ctx.stdout).to.contain('\nAnalytics are '); expect(ctx.stderr).to.equal(''); From 44adcdd7d237b4032a87cb7fe8ac327ae01bb686 Mon Sep 17 00:00:00 2001 From: Pedro Ramos Date: Mon, 3 Jun 2024 18:12:55 +0200 Subject: [PATCH 2/2] Set up analytics config file properly for every test --- test/integration/config/analytics.test.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/test/integration/config/analytics.test.ts b/test/integration/config/analytics.test.ts index f1eadfe0640..7ac5d4d04a6 100644 --- a/test/integration/config/analytics.test.ts +++ b/test/integration/config/analytics.test.ts @@ -1,11 +1,22 @@ import { expect, test } from '@oclif/test'; +import { fileCleanup } from '../../helpers'; + +const analyticsConfigFilePath = './test/fixtures/.asyncapi-analytics'; describe('config:analytics', () => { + beforeEach(() => { + process.env = Object.assign(process.env, { ASYNCAPI_METRICS_CONFIG_PATH: analyticsConfigFilePath }); + }); + + afterEach(() => { + fileCleanup(analyticsConfigFilePath); + }); + describe('with disable flag', () => { test .stderr() .stdout() - .command(['ASYNCAPI_METRICS_CONFIG_PATH=./test/fixtures/.asyncapi-analytics', 'config:analytics', '--disable']) + .command(['config:analytics', '--disable']) .it('should show a successful message once the analytics are disabled', async (ctx, done) => { expect(ctx.stdout).to.equal('\nAnalytics disabled.\n\n'); expect(ctx.stderr).to.equal(''); @@ -17,7 +28,7 @@ describe('config:analytics', () => { test .stderr() .stdout() - .command(['ASYNCAPI_METRICS_CONFIG_PATH=./test/fixtures/.asyncapi-analytics', 'config:analytics', '--enable']) + .command(['config:analytics', '--enable']) .it('should show a successful message once the analytics are enabled', (ctx, done) => { expect(ctx.stdout).to.equal('\nAnalytics enabled.\n\n'); expect(ctx.stderr).to.equal(''); @@ -29,7 +40,7 @@ describe('config:analytics', () => { test .stderr() .stdout() - .command(['ASYNCAPI_METRICS_CONFIG_PATH=./test/fixtures/.asyncapi-analytics', 'config:analytics']) + .command(['config:analytics']) .it('should show informational message when no flags are used', (ctx, done) => { expect(ctx.stdout).to.equal('\nPlease append the "--disable" flag to the command in case you prefer to disable analytics, or use the "--enable" flag if you want to enable analytics back again. In case you do not know the analytics current status, then you can append the "--status" flag to be aware of it.\n\n'); expect(ctx.stderr).to.equal(''); @@ -41,7 +52,7 @@ describe('config:analytics', () => { test .stderr() .stdout() - .command(['ASYNCAPI_METRICS_CONFIG_PATH=./test/fixtures/.asyncapi-analytics', 'config:analytics', '--status']) + .command(['config:analytics', '--status']) .it('should show a different informational message depending on the analytics status', (ctx, done) => { expect(ctx.stdout).to.contain('\nAnalytics are '); expect(ctx.stderr).to.equal('');