@@ -12,7 +12,6 @@ import { powerPlatform } from '../../../../utils/powerPlatform.js';
12
12
import { session } from '../../../../utils/session.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-publish.js' ;
17
16
import { accessToken } from '../../../../utils/accessToken.js' ;
18
17
@@ -38,6 +37,19 @@ describe(commands.SOLUTION_PUBLISH, () => {
38
37
}
39
38
]
40
39
} ;
40
+ const solutionResponse = {
41
+ solutionid : validId ,
42
+ uniquename : validName ,
43
+ version : '1.0.0.0' ,
44
+ installedon : '2021-10-01T21:54:14Z' ,
45
+ solutionpackageversion : null ,
46
+ friendlyname : validName ,
47
+ versionnumber : 860052 ,
48
+ publisherid : {
49
+ friendlyname : 'CDS Default Publisher' ,
50
+ publisherid : '00000001-0000-0000-0000-00000000005a'
51
+ }
52
+ } ;
41
53
//#endregion
42
54
43
55
let log : string [ ] ;
@@ -76,7 +88,8 @@ describe(commands.SOLUTION_PUBLISH, () => {
76
88
request . get ,
77
89
powerPlatform . getDynamicsInstanceApiUrl ,
78
90
cli . promptForConfirmation ,
79
- cli . executeCommandWithOutput
91
+ cli . executeCommandWithOutput ,
92
+ powerPlatform . getSolutionByName
80
93
] ) ;
81
94
} ) ;
82
95
@@ -121,34 +134,14 @@ describe(commands.SOLUTION_PUBLISH, () => {
121
134
it ( 'publishes the components of a specified solution owned by the currently signed-in user' , async ( ) => {
122
135
sinon . stub ( powerPlatform , 'getDynamicsInstanceApiUrl' ) . callsFake ( async ( ) => envUrl ) ;
123
136
124
- sinon . stub ( cli , 'executeCommandWithOutput' ) . callsFake ( async ( command ) : Promise < any > => {
125
- if ( command === ppSolutionGetCommand ) {
126
- return ( {
127
- stdout : `{
128
- "solutionid": "${ validId } ",
129
- "uniquename": "${ validName } ",
130
- "version": "1.0.0.0",
131
- "installedon": "2022-10-30T13:59:26Z",
132
- "solutionpackageversion": null,
133
- "friendlyname": "${ validName } ",
134
- "versionnumber": 1209676,
135
- "publisherid": {
136
- "friendlyname": "Default Publisher for org1547b730",
137
- "publisherid": "d21aab71-79e7-11dd-8874-00188b01e34f"
138
- }
139
- }`
140
- } ) ;
141
- }
142
-
143
- throw new CommandError ( 'Unknown case' ) ;
144
- } ) ;
137
+ sinon . stub ( powerPlatform , 'getSolutionByName' ) . resolves ( solutionResponse ) ;
145
138
146
139
sinon . stub ( request , 'get' ) . callsFake ( async ( opts ) => {
147
140
if ( opts . url === `https://contoso-dev.api.crm4.dynamics.com/api/data/v9.0/msdyn_solutioncomponentsummaries?$filter=(msdyn_solutionid eq ${ validId } )&$select=msdyn_componentlogicalname,msdyn_name&$orderby=msdyn_componentlogicalname asc&api-version=9.1` ) {
148
141
return validSolutionComponentsResult ;
149
142
}
150
143
151
- throw ' Invalid request' ;
144
+ throw ` Invalid request with opts ${ JSON . stringify ( opts ) } ` ;
152
145
} ) ;
153
146
154
147
sinon . stub ( request , 'post' ) . callsFake ( async ( opts ) => {
@@ -158,7 +151,7 @@ describe(commands.SOLUTION_PUBLISH, () => {
158
151
}
159
152
}
160
153
161
- throw ' Invalid request' ;
154
+ throw ` Invalid request with opts ${ JSON . stringify ( opts ) } ` ;
162
155
} ) ;
163
156
164
157
await assert . doesNotReject ( command . action ( logger , {
@@ -173,34 +166,14 @@ describe(commands.SOLUTION_PUBLISH, () => {
173
166
it ( 'publishes the components of a specified solution owned by the currently signed-in user and waits for completion' , async ( ) => {
174
167
sinon . stub ( powerPlatform , 'getDynamicsInstanceApiUrl' ) . callsFake ( async ( ) => envUrl ) ;
175
168
176
- sinon . stub ( cli , 'executeCommandWithOutput' ) . callsFake ( async ( command ) : Promise < any > => {
177
- if ( command === ppSolutionGetCommand ) {
178
- return ( {
179
- stdout : `{
180
- "solutionid": "${ validId } ",
181
- "uniquename": "${ validName } ",
182
- "version": "1.0.0.0",
183
- "installedon": "2022-10-30T13:59:26Z",
184
- "solutionpackageversion": null,
185
- "friendlyname": "${ validName } ",
186
- "versionnumber": 1209676,
187
- "publisherid": {
188
- "friendlyname": "Default Publisher for org1547b730",
189
- "publisherid": "d21aab71-79e7-11dd-8874-00188b01e34f"
190
- }
191
- }`
192
- } ) ;
193
- }
194
-
195
- throw new CommandError ( 'Unknown case' ) ;
196
- } ) ;
169
+ sinon . stub ( powerPlatform , 'getSolutionByName' ) . resolves ( solutionResponse ) ;
197
170
198
171
sinon . stub ( request , 'get' ) . callsFake ( async ( opts ) => {
199
172
if ( opts . url === `https://contoso-dev.api.crm4.dynamics.com/api/data/v9.0/msdyn_solutioncomponentsummaries?$filter=(msdyn_solutionid eq ${ validId } )&$select=msdyn_componentlogicalname,msdyn_name&$orderby=msdyn_componentlogicalname asc&api-version=9.1` ) {
200
173
return validSolutionComponentsResult ;
201
174
}
202
175
203
- throw ' Invalid request' ;
176
+ throw ` Invalid request with opts ${ JSON . stringify ( opts ) } ` ;
204
177
} ) ;
205
178
206
179
sinon . stub ( request , 'post' ) . callsFake ( async ( opts ) => {
@@ -210,7 +183,7 @@ describe(commands.SOLUTION_PUBLISH, () => {
210
183
}
211
184
}
212
185
213
- throw ' Invalid request' ;
186
+ throw ` Invalid request with opts ${ JSON . stringify ( opts ) } ` ;
214
187
} ) ;
215
188
216
189
await command . action ( logger , {
0 commit comments