Skip to content

Commit bbad2ff

Browse files
committed
chore: add username flag to suppress errors
1 parent ad0cad9 commit bbad2ff

File tree

1 file changed

+17
-43
lines changed

1 file changed

+17
-43
lines changed

test/commands/force/apex/log/tail.test.ts

Lines changed: 17 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import { createSandbox, SinonSandbox } from 'sinon';
1010
import { Connection, Org } from '@salesforce/core';
1111

1212
const logString = {
13-
log:
14-
'52.0 APEX_CODE,FINEST;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;NBA,INFO;SYSTEM,DEBUG'
13+
log: '52.0 APEX_CODE,FINEST;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;NBA,INFO;SYSTEM,DEBUG'
1514
};
1615
const streamingClient = {
1716
handshake: async (): Promise<void> => Promise.resolve(),
@@ -21,14 +20,13 @@ const TEST_USERNAME = '[email protected]';
2120

2221
describe('force:apex:log:tail', () => {
2322
let sandboxStub: SinonSandbox;
23+
const DUMMY_USERNAME: string = '[email protected]';
2424

2525
beforeEach(() => {
2626
sandboxStub = createSandbox();
2727

2828
sandboxStub.stub(Org, 'create').resolves(Org.prototype);
29-
sandboxStub
30-
.stub(Org.prototype, 'getConnection')
31-
.returns(Connection.prototype);
29+
sandboxStub.stub(Org.prototype, 'getConnection').returns(Connection.prototype);
3230
sandboxStub.stub(Org.prototype, 'getUsername').returns(TEST_USERNAME);
3331
sandboxStub.stub(Org.prototype, 'getOrgId').returns('abc123');
3432
});
@@ -37,17 +35,15 @@ describe('force:apex:log:tail', () => {
3735
sandboxStub.restore();
3836
});
3937
test
40-
.withOrg({ username: '[email protected]' }, true)
38+
.withOrg({ username: DUMMY_USERNAME }, true)
4139
.stub(LogService.prototype, 'prepareTraceFlag', () => undefined)
4240
.stub(LogService.prototype, 'getLogById', async () => logString)
43-
.stub(LogService.prototype, 'createStreamingClient', async function(
44-
this: LogService
45-
) {
41+
.stub(LogService.prototype, 'createStreamingClient', async function(this: LogService) {
4642
await this.logCallback({ sobject: { Id: 'xxxxxx' } });
4743
return streamingClient;
4844
})
4945
.stdout()
50-
.command(['force:apex:log:tail'])
46+
.command(['force:apex:log:tail', '-u', DUMMY_USERNAME])
5147
.it('should print the log with the default command', ctx => {
5248
expect(ctx.stdout).to.contain(logString.log);
5349
});
@@ -59,33 +55,22 @@ describe('force:apex:log:tail', () => {
5955
return streamingClient;
6056
})
6157
.stdout()
62-
.command(['force:apex:log:tail'])
58+
.command(['force:apex:log:tail', '-u', DUMMY_USERNAME])
6359
.it('should print nothing if no log is returned', ctx => {
6460
expect(ctx.stdout).to.contain('');
6561
});
6662
test
6763
.withOrg({ username: '[email protected]' }, true)
6864
.stub(LogService.prototype, 'prepareTraceFlag', () => undefined)
6965
.stub(LogService.prototype, 'getLogById', async () => logString)
70-
.stub(LogService.prototype, 'createStreamingClient', async function(
71-
this: LogService
72-
) {
66+
.stub(LogService.prototype, 'createStreamingClient', async function(this: LogService) {
7367
await this.logCallback({ sobject: { Id: 'xxxxxx' } });
7468
return streamingClient;
7569
})
7670
.stdout()
77-
.command([
78-
'force:apex:log:tail',
79-
'--targetusername',
80-
81-
'--json'
82-
])
71+
.command(['force:apex:log:tail', '--targetusername', '[email protected]', '--json'])
8372
.it('should print the log in json', ctx => {
84-
const logResult = JSON.stringify(
85-
{ status: 0, result: logString.log },
86-
null,
87-
2
88-
);
73+
const logResult = JSON.stringify({ status: 0, result: logString.log }, null, 2);
8974
expect(ctx.stdout).to.contain(logResult);
9075
});
9176
test
@@ -96,12 +81,7 @@ describe('force:apex:log:tail', () => {
9681
return streamingClient;
9782
})
9883
.stdout()
99-
.command([
100-
'force:apex:log:tail',
101-
'--targetusername',
102-
103-
'--json'
104-
])
84+
.command(['force:apex:log:tail', '--targetusername', '[email protected]', '--json'])
10585
.it('should return json output if no logs were found', ctx => {
10686
const emptyResult = JSON.stringify({ status: 0 }, null, 2);
10787
expect(ctx.stdout).to.equal(`${emptyResult}\n`);
@@ -110,43 +90,37 @@ describe('force:apex:log:tail', () => {
11090
.withOrg({ username: '[email protected]' }, true)
11191
.stub(LogService.prototype, 'prepareTraceFlag', () => undefined)
11292
.stub(LogService.prototype, 'getLogById', async () => logString)
113-
.stub(LogService.prototype, 'createStreamingClient', async function(
114-
this: LogService
115-
) {
93+
.stub(LogService.prototype, 'createStreamingClient', async function(this: LogService) {
11694
await this.logCallback({ sobject: { Id: 'xxxxxx' } });
11795
return streamingClient;
11896
})
11997
.stdout()
120-
.command(['force:apex:log:tail', '-c'])
98+
.command(['force:apex:log:tail', '-c', '-u', DUMMY_USERNAME])
12199
.it('should pass through colorization of the logs', ctx => {
122100
expect(ctx.stdout).to.contain(logString.log);
123101
});
124102
test
125103
.withOrg({ username: '[email protected]' }, true)
126104
.stub(LogService.prototype, 'getLogById', async () => logString)
127-
.stub(LogService.prototype, 'createStreamingClient', async function(
128-
this: LogService
129-
) {
105+
.stub(LogService.prototype, 'createStreamingClient', async function(this: LogService) {
130106
await this.logCallback({ sobject: { Id: 'xxxxxx' } });
131107
return streamingClient;
132108
})
133109
.stdout()
134-
.command(['force:apex:log:tail', '-s'])
110+
.command(['force:apex:log:tail', '-s', '-u', DUMMY_USERNAME])
135111
.it('should skip the trace flag creation', ctx => {
136112
expect(ctx.stdout).to.contain(logString.log);
137113
});
138114
test
139115
.withOrg({ username: '[email protected]' }, true)
140116
.stub(LogService.prototype, 'prepareTraceFlag', () => undefined)
141117
.stub(LogService.prototype, 'getLogById', async () => logString)
142-
.stub(LogService.prototype, 'createStreamingClient', async function(
143-
this: LogService
144-
) {
118+
.stub(LogService.prototype, 'createStreamingClient', async function(this: LogService) {
145119
await this.logCallback({ sobject: { Id: 'xxxxxx' } });
146120
return streamingClient;
147121
})
148122
.stdout()
149-
.command(['force:apex:log:tail', '-d', ''])
123+
.command(['force:apex:log:tail', '-d', '', '-u', DUMMY_USERNAME])
150124
.it('should accept a debug level parameter', ctx => {
151125
expect(ctx.stdout).to.contain(logString.log);
152126
});

0 commit comments

Comments
 (0)