@@ -22,8 +22,7 @@ describe("apphosting rollouts", () => {
22
22
const gitRepoLinkId = `${ user } -${ repo } ` ;
23
23
const buildAndRolloutId = "build-2024-10-01-001" ;
24
24
25
- let getBackendForLocationStub : sinon . SinonStub ;
26
- let getBackendForAmbiguousLocationStub : sinon . SinonStub ;
25
+ let getBackend : sinon . SinonStub ;
27
26
let getRepoDetailsFromBackendStub : sinon . SinonStub ;
28
27
let listAllBranchesStub : sinon . SinonStub ;
29
28
let getGitHubBranchStub : sinon . SinonStub ;
@@ -36,12 +35,7 @@ describe("apphosting rollouts", () => {
36
35
let sleepStub : sinon . SinonStub ;
37
36
38
37
beforeEach ( ( ) => {
39
- getBackendForLocationStub = sinon
40
- . stub ( backend , "getBackendForLocation" )
41
- . throws ( "unexpected getBackendForLocation call" ) ;
42
- getBackendForAmbiguousLocationStub = sinon
43
- . stub ( backend , "getBackendForAmbiguousLocation" )
44
- . throws ( "unexpected getBackendForAmbiguousLocation call" ) ;
38
+ getBackend = sinon . stub ( backend , "getBackend" ) . throws ( "unexpected getBackend call" ) ;
45
39
getRepoDetailsFromBackendStub = sinon
46
40
. stub ( devConnect , "getRepoDetailsFromBackend" )
47
41
. throws ( "unexpected getRepoDetailsFromBackend call" ) ;
@@ -149,8 +143,7 @@ describe("apphosting rollouts", () => {
149
143
150
144
describe ( "createRollout" , ( ) => {
151
145
it ( "should create a new rollout from user-specified branch" , async ( ) => {
152
- getBackendForLocationStub . resolves ( backend ) ;
153
- getBackendForAmbiguousLocationStub . resolves ( backend ) ;
146
+ getBackend . resolves ( backend ) ;
154
147
getRepoDetailsFromBackendStub . resolves ( repoLinkDetails ) ;
155
148
listAllBranchesStub . resolves ( branches ) ;
156
149
getGitHubBranchStub . resolves ( branchInfo ) ;
@@ -160,16 +153,15 @@ describe("apphosting rollouts", () => {
160
153
pollOperationStub . onFirstCall ( ) . resolves ( rollout ) ;
161
154
pollOperationStub . onSecondCall ( ) . resolves ( build ) ;
162
155
163
- await createRollout ( backendId , projectId , location , branchId , undefined , true ) ;
156
+ await createRollout ( backendId , projectId , branchId , undefined , true ) ;
164
157
165
158
expect ( createBuildStub ) . to . be . called ;
166
159
expect ( createRolloutStub ) . to . be . called ;
167
160
expect ( pollOperationStub ) . to . be . called ;
168
161
} ) ;
169
162
170
163
it ( "should create a new rollout from user-specified commit" , async ( ) => {
171
- getBackendForLocationStub . resolves ( backend ) ;
172
- getBackendForAmbiguousLocationStub . resolves ( backend ) ;
164
+ getBackend . resolves ( backend ) ;
173
165
getRepoDetailsFromBackendStub . resolves ( repoLinkDetails ) ;
174
166
getGitHubCommitStub . resolves ( commitInfo ) ;
175
167
getNextRolloutIdStub . resolves ( buildAndRolloutId ) ;
@@ -178,16 +170,15 @@ describe("apphosting rollouts", () => {
178
170
pollOperationStub . onFirstCall ( ) . resolves ( rollout ) ;
179
171
pollOperationStub . onSecondCall ( ) . resolves ( build ) ;
180
172
181
- await createRollout ( backendId , projectId , location , undefined , commitSha , true ) ;
173
+ await createRollout ( backendId , projectId , undefined , commitSha , true ) ;
182
174
183
175
expect ( createBuildStub ) . to . be . called ;
184
176
expect ( createRolloutStub ) . to . be . called ;
185
177
expect ( pollOperationStub ) . to . be . called ;
186
178
} ) ;
187
179
188
180
it ( "should prompt user for a branch if branch or commit ID is not specified" , async ( ) => {
189
- getBackendForLocationStub . resolves ( backend ) ;
190
- getBackendForAmbiguousLocationStub . resolves ( backend ) ;
181
+ getBackend . resolves ( backend ) ;
191
182
getRepoDetailsFromBackendStub . resolves ( repoLinkDetails ) ;
192
183
promptGitHubBranchStub . resolves ( branchId ) ;
193
184
getGitHubBranchStub . resolves ( branchInfo ) ;
@@ -197,7 +188,7 @@ describe("apphosting rollouts", () => {
197
188
pollOperationStub . onFirstCall ( ) . resolves ( rollout ) ;
198
189
pollOperationStub . onSecondCall ( ) . resolves ( build ) ;
199
190
200
- await createRollout ( backendId , projectId , location , undefined , undefined , false ) ;
191
+ await createRollout ( backendId , projectId , undefined , undefined , false ) ;
201
192
202
193
expect ( promptGitHubBranchStub ) . to . be . called ;
203
194
expect ( createBuildStub ) . to . be . called ;
@@ -206,33 +197,31 @@ describe("apphosting rollouts", () => {
206
197
} ) ;
207
198
208
199
it ( "should throw an error if GitHub branch is not found" , async ( ) => {
209
- getBackendForLocationStub . resolves ( backend ) ;
210
- getBackendForAmbiguousLocationStub . resolves ( backend ) ;
200
+ getBackend . resolves ( backend ) ;
211
201
getRepoDetailsFromBackendStub . resolves ( repoLinkDetails ) ;
212
202
listAllBranchesStub . resolves ( branches ) ;
213
203
214
204
await expect (
215
- createRollout ( backendId , projectId , location , "invalid-branch" , undefined , true ) ,
205
+ createRollout ( backendId , projectId , "invalid-branch" , undefined , true ) ,
216
206
) . to . be . rejectedWith ( / U n r e c o g n i z e d g i t b r a n c h / ) ;
217
207
} ) ;
218
208
219
209
it ( "should throw an error if GitHub commit is not found" , async ( ) => {
220
- getBackendForLocationStub . resolves ( backend ) ;
221
- getBackendForAmbiguousLocationStub . resolves ( backend ) ;
210
+ getBackend . resolves ( backend ) ;
222
211
getRepoDetailsFromBackendStub . resolves ( repoLinkDetails ) ;
223
212
getGitHubCommitStub . rejects ( new FirebaseError ( "error" , { status : 422 } ) ) ;
224
213
225
214
await expect (
226
- createRollout ( backendId , projectId , location , undefined , commitSha , true ) ,
215
+ createRollout ( backendId , projectId , undefined , commitSha , true ) ,
227
216
) . to . be . rejectedWith ( / U n r e c o g n i z e d g i t c o m m i t / ) ;
228
217
} ) ;
229
218
230
219
it ( "should throw an error if --force flag is specified but --git-branch and --git-commit are missing" , async ( ) => {
231
- getBackendForLocationStub . resolves ( backend ) ;
220
+ getBackend . resolves ( backend ) ;
232
221
getRepoDetailsFromBackendStub . resolves ( repoLinkDetails ) ;
233
222
234
223
await expect (
235
- createRollout ( backendId , projectId , location , undefined , undefined , true ) ,
224
+ createRollout ( backendId , projectId , undefined , undefined , true ) ,
236
225
) . to . be . rejectedWith ( / F a i l e d t o c r e a t e r o l l o u t w i t h - - f o r c e o p t i o n / ) ;
237
226
} ) ;
238
227
} ) ;
0 commit comments