@@ -155,32 +155,32 @@ describe('AppBuilder Walkthrough', function () {
155
155
} )
156
156
157
157
describe ( 'Create project' , function ( ) {
158
- let sandbox : sinon . SinonSandbox
158
+ const workspaceUri = vscode . workspace . workspaceFolders ?. [ 0 ] ?. uri
159
+ const prevInfo = 'random text'
160
+ assert . ok ( workspaceUri )
159
161
160
- beforeEach ( function ( ) {
161
- sandbox = sinon . createSandbox ( )
162
+ before ( async function ( ) {
163
+ await fs . delete ( vscode . Uri . joinPath ( workspaceUri , 'template.yaml' ) , { force : true } )
162
164
} )
163
165
164
- afterEach ( function ( ) {
165
- sandbox . restore ( )
166
+ beforeEach ( async function ( ) {
167
+ await fs . writeFile ( vscode . Uri . joinPath ( workspaceUri , 'template.yaml' ) , prevInfo )
168
+ } )
169
+
170
+ afterEach ( async function ( ) {
171
+ await fs . delete ( vscode . Uri . joinPath ( workspaceUri , 'template.yaml' ) , { force : true } )
166
172
} )
167
173
168
174
it ( 'open existing template' , async function ( ) {
169
- // Given
170
- const workspaceUri = vscode . workspace . workspaceFolders ?. [ 0 ] ?. uri
171
- assert . ok ( workspaceUri )
175
+ // Given no template exist
176
+ await fs . delete ( vscode . Uri . joinPath ( workspaceUri , 'template.yaml' ) , { force : true } )
172
177
// When
173
178
await genWalkthroughProject ( 'CustomTemplate' , workspaceUri , undefined )
174
- // Then
179
+ // Then nothing should be created
175
180
assert . equal ( await fs . exists ( vscode . Uri . joinPath ( workspaceUri , 'template.yaml' ) ) , false )
176
181
} )
177
182
178
183
it ( 'build an app with appcomposer overwrite' , async function ( ) {
179
- // Given
180
- const workspaceUri = vscode . workspace . workspaceFolders ?. [ 0 ] ?. uri
181
- assert . ok ( workspaceUri )
182
- await fs . writeFile ( vscode . Uri . joinPath ( workspaceUri , 'template.yaml' ) , 'random text' )
183
- const prevInfo = await fs . readFileText ( vscode . Uri . joinPath ( workspaceUri , 'template.yaml' ) )
184
184
getTestWindow ( ) . onDidShowMessage ( ( message ) => {
185
185
message . selectItem ( 'Yes' )
186
186
} )
@@ -192,10 +192,6 @@ describe('AppBuilder Walkthrough', function () {
192
192
193
193
it ( 'build an app with appcomposer no overwrite' , async function ( ) {
194
194
// Given
195
- const workspaceUri = vscode . workspace . workspaceFolders ?. [ 0 ] ?. uri
196
- assert . ok ( workspaceUri )
197
- await fs . writeFile ( vscode . Uri . joinPath ( workspaceUri , 'template.yaml' ) , 'random text' )
198
- const prevInfo = await fs . readFileText ( vscode . Uri . joinPath ( workspaceUri , 'template.yaml' ) )
199
195
getTestWindow ( ) . onDidShowMessage ( ( message ) => {
200
196
message . selectItem ( 'No' )
201
197
} )
@@ -213,11 +209,6 @@ describe('AppBuilder Walkthrough', function () {
213
209
214
210
it ( 'download serverlessland proj' , async function ( ) {
215
211
// Given
216
- const workspaceUri = vscode . workspace . workspaceFolders ?. [ 0 ] ?. uri
217
- assert . ok ( workspaceUri )
218
- // makesure template exist
219
- await fs . writeFile ( vscode . Uri . joinPath ( workspaceUri , 'template.yaml' ) , '' )
220
- const prevInfo = await fs . readFileText ( vscode . Uri . joinPath ( workspaceUri , 'template.yaml' ) )
221
212
// select overwrite
222
213
getTestWindow ( ) . onDidShowMessage ( ( message ) => {
223
214
message . selectItem ( 'Yes' )
@@ -231,11 +222,6 @@ describe('AppBuilder Walkthrough', function () {
231
222
232
223
it ( 'download serverlessland proj no overwrite' , async function ( ) {
233
224
// Given existing template.yaml
234
- const workspaceUri = vscode . workspace . workspaceFolders ?. [ 0 ] ?. uri
235
- assert . ok ( workspaceUri )
236
- // makesure template exist
237
- await fs . writeFile ( vscode . Uri . joinPath ( workspaceUri , 'template.yaml' ) , '' )
238
- const prevInfo = await fs . readFileText ( vscode . Uri . joinPath ( workspaceUri , 'template.yaml' ) )
239
225
// select do not overwrite
240
226
getTestWindow ( ) . onDidShowMessage ( ( message ) => {
241
227
message . selectItem ( 'No' )
0 commit comments