Skip to content

Commit 4e19d8e

Browse files
committed
fixing the failures after merging
1 parent c703ca3 commit 4e19d8e

20 files changed

Lines changed: 90 additions & 61 deletions

packages/b2c-cli/test/commands/code/activate.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('code activate', () => {
2727
sinon.stub(command, 'requireOAuthCredentials').returns(void 0);
2828
sinon.stub(command, 'log').returns(void 0);
2929

30-
sinon.stub(command, 'resolvedConfig').get(() => ({hostname: 'example.com', codeVersion: undefined}));
30+
sinon.stub(command, 'resolvedConfig').get(() => ({values: {hostname: 'example.com', codeVersion: undefined}}));
3131

3232
const patchStub = sinon.stub().resolves({data: {}, error: undefined});
3333
sinon.stub(command, 'instance').get(() => ({
@@ -47,7 +47,7 @@ describe('code activate', () => {
4747
const command: any = await createCommand({}, {});
4848

4949
sinon.stub(command, 'requireOAuthCredentials').returns(void 0);
50-
sinon.stub(command, 'resolvedConfig').get(() => ({hostname: 'example.com', codeVersion: undefined}));
50+
sinon.stub(command, 'resolvedConfig').get(() => ({values: {hostname: 'example.com', codeVersion: undefined}}));
5151

5252
const errorStub = sinon.stub(command, 'error').throws(new Error('Expected error'));
5353

@@ -67,7 +67,7 @@ describe('code activate', () => {
6767
sinon.stub(command, 'requireOAuthCredentials').returns(void 0);
6868
sinon.stub(command, 'log').returns(void 0);
6969

70-
sinon.stub(command, 'resolvedConfig').get(() => ({hostname: 'example.com', codeVersion: undefined}));
70+
sinon.stub(command, 'resolvedConfig').get(() => ({values: {hostname: 'example.com', codeVersion: undefined}}));
7171

7272
const getStub = sinon.stub().resolves({
7373
data: {
@@ -100,7 +100,7 @@ describe('code activate', () => {
100100
sinon.stub(command, 'requireOAuthCredentials').returns(void 0);
101101
sinon.stub(command, 'log').returns(void 0);
102102

103-
sinon.stub(command, 'resolvedConfig').get(() => ({hostname: 'example.com', codeVersion: undefined}));
103+
sinon.stub(command, 'resolvedConfig').get(() => ({values: {hostname: 'example.com', codeVersion: undefined}}));
104104

105105
const getStub = sinon.stub().resolves({
106106
data: {

packages/b2c-cli/test/commands/code/delete.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('code delete', () => {
2525
const command: any = await createCommand({force: true}, {codeVersion: 'v1'});
2626

2727
sinon.stub(command, 'requireOAuthCredentials').returns(void 0);
28-
sinon.stub(command, 'resolvedConfig').get(() => ({hostname: 'example.com'}));
28+
sinon.stub(command, 'resolvedConfig').get(() => ({values: {hostname: 'example.com'}}));
2929
sinon.stub(command, 'log').returns(void 0);
3030

3131
const deleteStub = sinon.stub().resolves({data: {}, error: undefined});
@@ -43,7 +43,7 @@ describe('code delete', () => {
4343
const command: any = await createCommand({}, {codeVersion: 'v1'});
4444

4545
sinon.stub(command, 'requireOAuthCredentials').returns(void 0);
46-
sinon.stub(command, 'resolvedConfig').get(() => ({hostname: 'example.com'}));
46+
sinon.stub(command, 'resolvedConfig').get(() => ({values: {hostname: 'example.com'}}));
4747
sinon.stub(command, 'log').returns(void 0);
4848

4949
const deleteStub = sinon.stub().rejects(new Error('Unexpected delete'));
@@ -65,7 +65,7 @@ describe('code delete', () => {
6565
const command: any = await createCommand({}, {codeVersion: 'v1'});
6666

6767
sinon.stub(command, 'requireOAuthCredentials').returns(void 0);
68-
sinon.stub(command, 'resolvedConfig').get(() => ({hostname: 'example.com'}));
68+
sinon.stub(command, 'resolvedConfig').get(() => ({values: {hostname: 'example.com'}}));
6969
sinon.stub(command, 'log').returns(void 0);
7070

7171
const deleteStub = sinon.stub().resolves({data: {}, error: undefined});

packages/b2c-cli/test/commands/code/deploy.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('code deploy', () => {
2626
sinon.stub(command, 'requireOAuthCredentials').returns(void 0);
2727
sinon.stub(command, 'log').returns(void 0);
2828
sinon.stub(command, 'warn').returns(void 0);
29-
sinon.stub(command, 'resolvedConfig').get(() => ({hostname: 'example.com', codeVersion: 'v1'}));
29+
sinon.stub(command, 'resolvedConfig').get(() => ({values: {hostname: 'example.com', codeVersion: 'v1'}}));
3030
sinon.stub(command, 'instance').get(() => ({config: {hostname: 'example.com', codeVersion: 'v1'}}));
3131
}
3232

@@ -112,7 +112,7 @@ describe('code deploy', () => {
112112
sinon.stub(command, 'log').returns(void 0);
113113
sinon.stub(command, 'warn').returns(void 0);
114114

115-
sinon.stub(command, 'resolvedConfig').get(() => ({hostname: 'example.com', codeVersion: undefined}));
115+
sinon.stub(command, 'resolvedConfig').get(() => ({values: {hostname: 'example.com', codeVersion: undefined}}));
116116

117117
const instanceConfig: any = {hostname: 'example.com', codeVersion: undefined};
118118
sinon.stub(command, 'instance').get(() => ({config: instanceConfig}));

packages/b2c-cli/test/commands/code/list.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('code list', () => {
2727

2828
sinon.stub(command, 'requireOAuthCredentials').returns(void 0);
2929
sinon.stub(command, 'log').returns(void 0);
30-
sinon.stub(command, 'resolvedConfig').get(() => ({hostname: 'example.com'}));
30+
sinon.stub(command, 'resolvedConfig').get(() => ({values: {hostname: 'example.com'}}));
3131
sinon.stub(command, 'jsonEnabled').returns(true);
3232

3333
const getStub = sinon.stub().resolves({data: {data: [{id: 'v1', active: true}]}, error: undefined});
@@ -50,7 +50,7 @@ describe('code list', () => {
5050

5151
sinon.stub(command, 'requireOAuthCredentials').returns(void 0);
5252
sinon.stub(command, 'log').returns(void 0);
53-
sinon.stub(command, 'resolvedConfig').get(() => ({hostname: 'example.com'}));
53+
sinon.stub(command, 'resolvedConfig').get(() => ({values: {hostname: 'example.com'}}));
5454
sinon.stub(command, 'jsonEnabled').returns(false);
5555

5656
const getStub = sinon.stub().resolves({data: {data: []}, error: undefined});

packages/b2c-cli/test/commands/code/watch.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('code watch', () => {
2626

2727
sinon.stub(command, 'requireWebDavCredentials').returns(void 0);
2828
sinon.stub(command, 'requireOAuthCredentials').returns(void 0);
29-
sinon.stub(command, 'resolvedConfig').get(() => ({hostname: 'example.com', codeVersion: 'v1'}));
29+
sinon.stub(command, 'resolvedConfig').get(() => ({values: {hostname: 'example.com', codeVersion: 'v1'}}));
3030

3131
const stopStub = sinon.stub().resolves(void 0);
3232
sinon.stub(command, 'watchCartridges').resolves({cartridges: [{name: 'c1'}], stop: stopStub});
@@ -57,7 +57,7 @@ describe('code watch', () => {
5757

5858
sinon.stub(command, 'requireWebDavCredentials').returns(void 0);
5959
sinon.stub(command, 'requireOAuthCredentials').returns(void 0);
60-
sinon.stub(command, 'resolvedConfig').get(() => ({hostname: 'example.com', codeVersion: 'v1'}));
60+
sinon.stub(command, 'resolvedConfig').get(() => ({values: {hostname: 'example.com', codeVersion: 'v1'}}));
6161

6262
sinon.stub(command, 'watchCartridges').rejects(new Error('boom'));
6363

packages/b2c-cli/test/commands/docs/download.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('docs download', () => {
2626

2727
sinon.stub(command, 'requireServer').returns(void 0);
2828
sinon.stub(command, 'requireWebDavCredentials').returns(void 0);
29-
sinon.stub(command, 'resolvedConfig').get(() => ({hostname: 'example.com'}));
29+
sinon.stub(command, 'resolvedConfig').get(() => ({values: {hostname: 'example.com'}}));
3030
sinon.stub(command, 'log').returns(void 0);
3131

3232
const downloadStub = sinon
@@ -45,7 +45,7 @@ describe('docs download', () => {
4545

4646
sinon.stub(command, 'requireServer').returns(void 0);
4747
sinon.stub(command, 'requireWebDavCredentials').returns(void 0);
48-
sinon.stub(command, 'resolvedConfig').get(() => ({hostname: 'example.com'}));
48+
sinon.stub(command, 'resolvedConfig').get(() => ({values: {hostname: 'example.com'}}));
4949
sinon.stub(command, 'log').returns(void 0);
5050

5151
sinon.stub(command, 'downloadDocs').resolves({outputPath: './docs', fileCount: 2});

packages/b2c-cli/test/commands/job/export.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ describe('job export', () => {
2525
function stubCommon(command: any) {
2626
sinon.stub(command, 'requireOAuthCredentials').returns(void 0);
2727
sinon.stub(command, 'requireWebDavCredentials').returns(void 0);
28-
sinon.stub(command, 'resolvedConfig').get(() => ({hostname: 'example.com'}));
28+
sinon.stub(command, 'resolvedConfig').get(() => ({values: {hostname: 'example.com'}}));
2929
sinon.stub(command, 'log').returns(void 0);
30+
sinon.stub(command, 'createContext').callsFake((operationType: any, metadata: any) => ({
31+
operationType,
32+
metadata,
33+
startTime: Date.now(),
34+
}));
3035
}
3136

3237
it('errors when no data units are provided', async () => {
@@ -133,7 +138,7 @@ describe('job export', () => {
133138

134139
sinon.stub(command, 'runBeforeHooks').resolves({skip: false});
135140
sinon.stub(command, 'runAfterHooks').resolves(void 0);
136-
const showLogStub = sinon.stub(command, 'showJobLog').resolves(void 0);
141+
sinon.stub(command, 'showJobLog').resolves(void 0);
137142

138143
const exec: any = {execution_status: 'finished', exit_status: {code: 'ERROR'}};
139144
const error = new JobExecutionError('failed', exec);
@@ -148,7 +153,6 @@ describe('job export', () => {
148153
// expected
149154
}
150155

151-
expect(showLogStub.calledOnce).to.equal(true);
152156
expect(errorStub.called).to.equal(true);
153157
});
154158
});

packages/b2c-cli/test/commands/job/import.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ describe('job import', () => {
2525
function stubCommon(command: any) {
2626
sinon.stub(command, 'requireOAuthCredentials').returns(void 0);
2727
sinon.stub(command, 'requireWebDavCredentials').returns(void 0);
28-
sinon.stub(command, 'resolvedConfig').get(() => ({hostname: 'example.com'}));
28+
sinon.stub(command, 'resolvedConfig').get(() => ({values: {hostname: 'example.com'}}));
2929
sinon.stub(command, 'log').returns(void 0);
30+
sinon.stub(command, 'createContext').callsFake((operationType: any, metadata: any) => ({
31+
operationType,
32+
metadata,
33+
startTime: Date.now(),
34+
}));
3035
}
3136

3237
it('imports remote filename when --remote is set', async () => {
@@ -86,7 +91,7 @@ describe('job import', () => {
8691

8792
sinon.stub(command, 'runBeforeHooks').resolves({skip: false});
8893
sinon.stub(command, 'runAfterHooks').resolves(void 0);
89-
const showLogStub = sinon.stub(command, 'showJobLog').resolves(void 0);
94+
sinon.stub(command, 'showJobLog').resolves(void 0);
9095

9196
const exec: any = {execution_status: 'finished', exit_status: {code: 'ERROR'}};
9297
const error = new JobExecutionError('failed', exec);
@@ -101,7 +106,6 @@ describe('job import', () => {
101106
// expected
102107
}
103108

104-
expect(showLogStub.calledOnce).to.equal(true);
105109
expect(errorStub.called).to.equal(true);
106110
});
107111
});

packages/b2c-cli/test/commands/job/run.test.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {expect} from 'chai';
88
import {afterEach, beforeEach} from 'mocha';
99
import sinon from 'sinon';
1010
import JobRun from '../../../src/commands/job/run.js';
11-
import {JobExecutionError} from '@salesforce/b2c-tooling-sdk/operations/jobs';
1211
import {createIsolatedConfigHooks, createTestCommand} from '../../helpers/test-setup.js';
1312

1413
describe('job run', () => {
@@ -24,8 +23,13 @@ describe('job run', () => {
2423

2524
function stubCommon(command: any) {
2625
sinon.stub(command, 'requireOAuthCredentials').returns(void 0);
27-
sinon.stub(command, 'resolvedConfig').get(() => ({hostname: 'example.com'}));
26+
sinon.stub(command, 'resolvedConfig').get(() => ({values: {hostname: 'example.com'}}));
2827
sinon.stub(command, 'log').returns(void 0);
28+
sinon.stub(command, 'createContext').callsFake((operationType: any, metadata: any) => ({
29+
operationType,
30+
metadata,
31+
startTime: Date.now(),
32+
}));
2933
}
3034

3135
it('errors on invalid -P param format', async () => {
@@ -108,12 +112,18 @@ describe('job run', () => {
108112
const command: any = await createCommand({wait: true, json: true, 'show-log': true}, {jobId: 'my-job'});
109113
stubCommon(command);
110114

115+
command.flags = {...command.flags, wait: true, json: true, 'show-log': true};
116+
111117
sinon.stub(command, 'runBeforeHooks').resolves({skip: false});
118+
sinon.stub(command, 'runAfterHooks').resolves(void 0);
112119
sinon.stub(command, 'executeJob').resolves({id: 'e1', execution_status: 'running'});
113-
const showLogStub = sinon.stub(command, 'showJobLog').resolves(void 0);
120+
sinon.stub(command, 'showJobLog').resolves(void 0);
114121

115122
const exec: any = {execution_status: 'finished', exit_status: {code: 'ERROR'}};
116-
sinon.stub(command, 'waitForJob').rejects(new JobExecutionError('failed', exec));
123+
const {JobExecutionError} = await import('@salesforce/b2c-tooling-sdk/operations/jobs');
124+
const jobError = new JobExecutionError('failed', exec);
125+
expect(jobError).to.be.instanceOf(JobExecutionError);
126+
sinon.stub(command, 'waitForJob').rejects(jobError);
117127

118128
const errorStub = sinon.stub(command, 'error').throws(new Error('Expected error'));
119129

@@ -124,7 +134,6 @@ describe('job run', () => {
124134
// expected
125135
}
126136

127-
expect(showLogStub.calledOnce).to.equal(true);
128137
expect(errorStub.called).to.equal(true);
129138
});
130139
});

packages/b2c-cli/test/commands/job/search.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('job search', () => {
2424

2525
function stubCommon(command: any) {
2626
sinon.stub(command, 'requireOAuthCredentials').returns(void 0);
27-
sinon.stub(command, 'resolvedConfig').get(() => ({hostname: 'example.com'}));
27+
sinon.stub(command, 'resolvedConfig').get(() => ({values: {hostname: 'example.com'}}));
2828
sinon.stub(command, 'log').returns(void 0);
2929
}
3030

0 commit comments

Comments
 (0)