1
1
import assert from 'assert' ;
2
2
import sinon from 'sinon' ;
3
+ import { telemetry } from '../../../../telemetry.js' ;
3
4
import auth from '../../../../Auth.js' ;
4
5
import { cli } from '../../../../cli/cli.js' ;
5
6
import { CommandInfo } from '../../../../cli/CommandInfo.js' ;
6
7
import { Logger } from '../../../../cli/Logger.js' ;
7
8
import { CommandError } from '../../../../Command.js' ;
8
9
import request from '../../../../request.js' ;
9
- import { telemetry } from '../../../../telemetry.js' ;
10
10
import { pid } from '../../../../utils/pid.js' ;
11
- import { powerPlatform } from '../../../../utils/powerPlatform.js' ;
12
11
import { session } from '../../../../utils/session.js' ;
12
+ import { powerPlatform } from '../../../../utils/powerPlatform.js' ;
13
13
import { sinonUtil } from '../../../../utils/sinonUtil.js' ;
14
14
import commands from '../../commands.js' ;
15
- import ppSolutionGetCommand from './solution-get.js' ;
16
15
import command from './solution-remove.js' ;
17
16
import { accessToken } from '../../../../utils/accessToken.js' ;
18
17
@@ -23,6 +22,19 @@ describe(commands.SOLUTION_REMOVE, () => {
23
22
const validId = '00000001-0000-0000-0001-00000000009b' ;
24
23
const validName = 'Solution name' ;
25
24
const envUrl = "https://contoso-dev.api.crm4.dynamics.com" ;
25
+ const solutionResponse = {
26
+ solutionid : validId ,
27
+ uniquename : validName ,
28
+ version : '1.0.0.0' ,
29
+ installedon : '2021-10-01T21:54:14Z' ,
30
+ solutionpackageversion : null ,
31
+ friendlyname : validName ,
32
+ versionnumber : 860052 ,
33
+ publisherid : {
34
+ friendlyname : 'CDS Default Publisher' ,
35
+ publisherid : '00000001-0000-0000-0000-00000000005a'
36
+ }
37
+ } ;
26
38
//#endregion
27
39
28
40
let log : string [ ] ;
@@ -66,6 +78,7 @@ describe(commands.SOLUTION_REMOVE, () => {
66
78
sinonUtil . restore ( [
67
79
request . delete ,
68
80
powerPlatform . getDynamicsInstanceApiUrl ,
81
+ powerPlatform . getSolutionByName ,
69
82
cli . promptForConfirmation ,
70
83
cli . executeCommandWithOutput
71
84
] ) ;
@@ -129,28 +142,7 @@ describe(commands.SOLUTION_REMOVE, () => {
129
142
130
143
it ( 'removes the specified solution owned by the currently signed-in user when prompt confirmed' , async ( ) => {
131
144
sinon . stub ( powerPlatform , 'getDynamicsInstanceApiUrl' ) . callsFake ( async ( ) => envUrl ) ;
132
-
133
- sinon . stub ( cli , 'executeCommandWithOutput' ) . callsFake ( async ( command ) : Promise < any > => {
134
- if ( command === ppSolutionGetCommand ) {
135
- return ( {
136
- stdout : `{
137
- "solutionid": "${ validId } ",
138
- "uniquename": "${ validName } ",
139
- "version": "1.0.0.0",
140
- "installedon": "2022-10-30T13:59:26Z",
141
- "solutionpackageversion": null,
142
- "friendlyname": "${ validName } ",
143
- "versionnumber": 1209676,
144
- "publisherid": {
145
- "friendlyname": "Default Publisher for org1547b730",
146
- "publisherid": "d21aab71-79e7-11dd-8874-00188b01e34f"
147
- }
148
- }`
149
- } ) ;
150
- }
151
-
152
- throw new CommandError ( 'Unknown case' ) ;
153
- } ) ;
145
+ sinon . stub ( powerPlatform , 'getSolutionByName' ) . resolves ( solutionResponse ) ;
154
146
155
147
sinon . stub ( request , 'delete' ) . callsFake ( async ( opts ) => {
156
148
if ( opts . url === `https://contoso-dev.api.crm4.dynamics.com/api/data/v9.1/solutions(${ validId } )` ) {
0 commit comments