@@ -19,8 +19,8 @@ describe(`Cursor Deploy Action`, () => {
19
19
And the tree hash used is the current repo tree hash
20
20
` ,
21
21
async ( ) => {
22
- const treeHash = 'b017ebdf289ba78787da4e9c3291f0b7959e7059'
23
- mockedUtils . getCurrentRepoTreeHash . mockResolvedValue ( treeHash )
22
+ const deployHash = 'b017ebdf289ba78787da4e9c3291f0b7959e7059'
23
+ mockedUtils . readFileFromS3 . mockResolvedValue ( deployHash )
24
24
mockedUtils . fileExistsInS3 . mockResolvedValue ( false )
25
25
26
26
const output = await cursorDeploy ( {
@@ -33,13 +33,13 @@ describe(`Cursor Deploy Action`, () => {
33
33
expectRollbackFileChecked ( 'my-bucket' , 'rollbacks/main' )
34
34
35
35
expectCursorFileUpdated ( {
36
- treeHash : treeHash ,
36
+ deployHash : deployHash ,
37
37
branch : 'main' ,
38
38
bucket : 'my-bucket' ,
39
39
key : 'deploys/main'
40
40
} )
41
41
42
- expect ( output . treeHash ) . toBe ( treeHash )
42
+ expect ( output . deployHash ) . toBe ( deployHash )
43
43
expect ( output . branchLabel ) . toBe ( 'main' )
44
44
}
45
45
)
@@ -53,9 +53,9 @@ describe(`Cursor Deploy Action`, () => {
53
53
And the tree hash used is the current repo tree hash
54
54
` ,
55
55
async ( ) => {
56
- const treeHash = '553b0cb96ac21ffc0583e5d8d72343b1faa90dfd'
56
+ const deployHash = '553b0cb96ac21ffc0583e5d8d72343b1faa90dfd'
57
57
const sanitizedBranch = 'lol-my-feature-branch-30-better'
58
- mockedUtils . getCurrentRepoTreeHash . mockResolvedValue ( treeHash )
58
+ mockedUtils . readFileFromS3 . mockResolvedValue ( deployHash )
59
59
mockedUtils . fileExistsInS3 . mockResolvedValue ( false )
60
60
61
61
const output = await cursorDeploy ( {
@@ -68,13 +68,13 @@ describe(`Cursor Deploy Action`, () => {
68
68
expectRollbackFileChecked ( 'my-bucket' , 'rollbacks/lol-my-feature-branch-30-better' )
69
69
70
70
expectCursorFileUpdated ( {
71
- treeHash : treeHash ,
71
+ deployHash : deployHash ,
72
72
branch : sanitizedBranch ,
73
73
bucket : 'my-bucket' ,
74
74
key : 'deploys/lol-my-feature-branch-30-better'
75
75
} )
76
76
77
- expect ( output . treeHash ) . toBe ( treeHash )
77
+ expect ( output . deployHash ) . toBe ( deployHash )
78
78
expect ( output . branchLabel ) . toBe ( sanitizedBranch )
79
79
}
80
80
)
@@ -87,8 +87,8 @@ describe(`Cursor Deploy Action`, () => {
87
87
And the action returns a error
88
88
` ,
89
89
async ( ) => {
90
- const treeHash = 'b017ebdf289ba78787da4e9c3291f0b7959e7059'
91
- mockedUtils . getCurrentRepoTreeHash . mockResolvedValue ( treeHash )
90
+ const deployHash = 'b017ebdf289ba78787da4e9c3291f0b7959e7059'
91
+ mockedUtils . readFileFromS3 . mockResolvedValue ( deployHash )
92
92
mockedUtils . fileExistsInS3 . mockResolvedValue ( true )
93
93
94
94
const promise = cursorDeploy ( {
@@ -118,12 +118,10 @@ describe(`Cursor Deploy Action`, () => {
118
118
And the tree hash used is the previous commit tree hash
119
119
` ,
120
120
async ( ) => {
121
- const currentTreeHash = 'b017ebdf289ba78787da4e9c3291f0b7959e7059'
122
- const commitTreeHash = '32439d157a7e346d117a6a3c47d511526bd45012'
121
+ const currentDeployHash = 'b017ebdf289ba78787da4e9c3291f0b7959e7059'
123
122
124
- mockedUtils . getCurrentRepoTreeHash . mockResolvedValue ( currentTreeHash )
123
+ mockedUtils . readFileFromS3 . mockResolvedValue ( currentDeployHash )
125
124
mockedUtils . fileExistsInS3 . mockResolvedValue ( false )
126
- mockedUtils . getTreeHashForCommitHash . mockResolvedValue ( commitTreeHash )
127
125
128
126
const output = await cursorDeploy ( {
129
127
bucket : 'my-prod-bucket' ,
@@ -134,11 +132,11 @@ describe(`Cursor Deploy Action`, () => {
134
132
135
133
expect ( mockedUtils . fileExistsInS3 ) . not . toHaveBeenCalled ( )
136
134
expect ( mockedUtils . isHeadAncestor ) . not . toHaveBeenCalled ( )
137
- expect ( mockedUtils . getTreeHashForCommitHash ) . toHaveBeenCalledWith ( 'HEAD^' )
135
+ expect ( mockedUtils . getCommitHashFromRef ) . toHaveBeenCalledWith ( 'HEAD^' )
138
136
139
137
expect ( mockedUtils . writeLineToFile ) . toHaveBeenCalledTimes ( 1 )
140
138
expect ( mockedUtils . writeLineToFile ) . toHaveBeenCalledWith ( {
141
- text : commitTreeHash ,
139
+ text : currentDeployHash ,
142
140
path : 'main'
143
141
} )
144
142
@@ -155,7 +153,7 @@ describe(`Cursor Deploy Action`, () => {
155
153
key : 'rollbacks/main'
156
154
} )
157
155
158
- expect ( output . treeHash ) . toBe ( commitTreeHash )
156
+ expect ( output . deployHash ) . toBe ( currentDeployHash )
159
157
expect ( output . branchLabel ) . toBe ( 'main' )
160
158
}
161
159
)
@@ -168,14 +166,12 @@ describe(`Cursor Deploy Action`, () => {
168
166
And the tree hash used is the tree hash of the passed commit hash
169
167
` ,
170
168
async ( ) => {
171
- const currentTreeHash = 'b017ebdf289ba78787da4e9c3291f0b7959e7059'
172
- const commitTreeHash = 'b6e1c0468f4705b8cd0f18a04cd28ef7b9da7425'
169
+ const currentDeployHash = 'b017ebdf289ba78787da4e9c3291f0b7959e7059'
173
170
const commitHash = 'fc24d309398cbf6d53237e05e4d2a8cd2de57cc7'
174
171
175
- mockedUtils . getCurrentRepoTreeHash . mockResolvedValue ( currentTreeHash )
172
+ mockedUtils . readFileFromS3 . mockResolvedValue ( currentDeployHash )
176
173
mockedUtils . fileExistsInS3 . mockResolvedValue ( false )
177
174
mockedUtils . isHeadAncestor . mockResolvedValue ( true )
178
- mockedUtils . getTreeHashForCommitHash . mockResolvedValue ( commitTreeHash )
179
175
180
176
const output = await cursorDeploy ( {
181
177
bucket : 'my-bucket' ,
@@ -186,11 +182,11 @@ describe(`Cursor Deploy Action`, () => {
186
182
187
183
expect ( mockedUtils . fileExistsInS3 ) . not . toHaveBeenCalled ( )
188
184
expect ( mockedUtils . isHeadAncestor ) . toHaveBeenCalledWith ( commitHash )
189
- expect ( mockedUtils . getTreeHashForCommitHash ) . toHaveBeenCalledWith ( commitHash )
185
+ expect ( mockedUtils . getCommitHashFromRef ) . toHaveBeenCalledWith ( commitHash )
190
186
191
187
expect ( mockedUtils . writeLineToFile ) . toHaveBeenCalledTimes ( 1 )
192
188
expect ( mockedUtils . writeLineToFile ) . toHaveBeenCalledWith ( {
193
- text : commitTreeHash ,
189
+ text : currentDeployHash ,
194
190
path : 'main'
195
191
} )
196
192
@@ -207,7 +203,7 @@ describe(`Cursor Deploy Action`, () => {
207
203
key : 'rollbacks/main'
208
204
} )
209
205
210
- expect ( output . treeHash ) . toBe ( commitTreeHash )
206
+ expect ( output . deployHash ) . toBe ( currentDeployHash )
211
207
expect ( output . branchLabel ) . toBe ( 'main' )
212
208
}
213
209
)
@@ -221,9 +217,9 @@ describe(`Cursor Deploy Action`, () => {
221
217
And the tree hash used is the tree hash of the passed commit hash
222
218
` ,
223
219
async ( ) => {
224
- const treeHash = 'b017ebdf289ba78787da4e9c3291f0b7959e7059'
220
+ const deployHash = 'b017ebdf289ba78787da4e9c3291f0b7959e7059'
225
221
226
- mockedUtils . getCurrentRepoTreeHash . mockResolvedValue ( treeHash )
222
+ mockedUtils . readFileFromS3 . mockResolvedValue ( deployHash )
227
223
mockedUtils . fileExistsInS3 . mockResolvedValue ( true )
228
224
mockedUtils . isHeadAncestor . mockResolvedValue ( true )
229
225
@@ -237,7 +233,7 @@ describe(`Cursor Deploy Action`, () => {
237
233
expectRollbackFileChecked ( 'my-bucket' , 'rollbacks/main' )
238
234
239
235
expectCursorFileUpdated ( {
240
- treeHash : treeHash ,
236
+ deployHash : deployHash ,
241
237
branch : 'main' ,
242
238
bucket : 'my-bucket' ,
243
239
key : 'deploys/main'
@@ -248,7 +244,7 @@ describe(`Cursor Deploy Action`, () => {
248
244
key : 'rollbacks/main'
249
245
} )
250
246
251
- expect ( output . treeHash ) . toBe ( treeHash )
247
+ expect ( output . deployHash ) . toBe ( deployHash )
252
248
expect ( output . branchLabel ) . toBe ( 'main' )
253
249
}
254
250
)
@@ -282,14 +278,12 @@ describe(`Cursor Deploy Action`, () => {
282
278
Then the action fails with an informative error
283
279
` ,
284
280
async ( ) => {
285
- const currentTreeHash = 'b017ebdf289ba78787da4e9c3291f0b7959e7059'
281
+ const currentDeployHash = 'b017ebdf289ba78787da4e9c3291f0b7959e7059'
286
282
const commitHash = 'fc24d309398cbf6d53237e05e4d2a8cd2de57cc7'
287
- const commitTreeHash = 'b6e1c0468f4705b8cd0f18a04cd28ef7b9da7425'
288
283
289
- mockedUtils . getCurrentRepoTreeHash . mockResolvedValue ( currentTreeHash )
284
+ mockedUtils . readFileFromS3 . mockResolvedValue ( currentDeployHash )
290
285
mockedUtils . fileExistsInS3 . mockResolvedValue ( false )
291
286
mockedUtils . isHeadAncestor . mockResolvedValue ( false )
292
- mockedUtils . getTreeHashForCommitHash . mockResolvedValue ( commitTreeHash )
293
287
294
288
const promise = cursorDeploy ( {
295
289
bucket : 'my-bucket' ,
@@ -370,14 +364,14 @@ describe('Branch Sanitize - branchNameToHostnameLabel', () => {
370
364
//#region Custom Assertions
371
365
372
366
function expectCursorFileUpdated ( args : {
373
- treeHash : string
367
+ deployHash : string
374
368
branch : string
375
369
bucket : string
376
370
key : string
377
371
} ) {
378
372
expect ( mockedUtils . writeLineToFile ) . toHaveBeenCalledTimes ( 1 )
379
373
expect ( mockedUtils . writeLineToFile ) . toHaveBeenCalledWith ( {
380
- text : args . treeHash ,
374
+ text : args . deployHash ,
381
375
path : args . branch
382
376
} )
383
377
0 commit comments