@@ -103,7 +103,7 @@ class TypesProvidingTest :
103
103
// Given
104
104
val fetchUri: (URI ) -> String = {
105
105
when (it) {
106
- URI (" https://raw.githubusercontent.com/some-owner/some-name/some-hash// action-types.yml" ) -> hostedByActionYml
106
+ URI (" https://raw.githubusercontent.com/some-owner/some-name/some-hash/action-types.yml" ) -> hostedByActionYml
107
107
else -> throw IOException ()
108
108
}
109
109
}
@@ -116,11 +116,31 @@ class TypesProvidingTest :
116
116
types shouldBe Pair (mapOf (" hosted-by-action-yml" to StringTyping ), TypingActualSource .ACTION )
117
117
}
118
118
119
+ test(" only hosted by the subaction (.yml)" ) {
120
+ // Given
121
+ val fetchUri: (URI ) -> String = {
122
+ when (it) {
123
+ URI (
124
+ " https://raw.githubusercontent.com/some-owner/some-name/some-hash/some-sub/action-types.yml" ,
125
+ ),
126
+ -> hostedByActionYml
127
+ else -> throw IOException ()
128
+ }
129
+ }
130
+ val actionCoord = ActionCoords (" some-owner" , " some-name/some-sub" , " v3" )
131
+
132
+ // When
133
+ val types = actionCoord.provideTypes(metadataRevision = CommitHash (" some-hash" ), fetchUri = fetchUri)
134
+
135
+ // Then
136
+ types shouldBe Pair (mapOf (" hosted-by-action-yml" to StringTyping ), TypingActualSource .ACTION )
137
+ }
138
+
119
139
test(" only hosted by the action (.yaml)" ) {
120
140
// Given
121
141
val fetchUri: (URI ) -> String = {
122
142
when (it) {
123
- URI (" https://raw.githubusercontent.com/some-owner/some-name/some-hash// action-types.yaml" ) -> hostedByActionYaml
143
+ URI (" https://raw.githubusercontent.com/some-owner/some-name/some-hash/action-types.yaml" ) -> hostedByActionYaml
124
144
else -> throw IOException ()
125
145
}
126
146
}
@@ -133,12 +153,32 @@ class TypesProvidingTest :
133
153
types shouldBe Pair (mapOf (" hosted-by-action-yaml" to StringTyping ), TypingActualSource .ACTION )
134
154
}
135
155
156
+ test(" only hosted by the subaction (.yaml)" ) {
157
+ // Given
158
+ val fetchUri: (URI ) -> String = {
159
+ when (it) {
160
+ URI (
161
+ " https://raw.githubusercontent.com/some-owner/some-name/some-hash/some-sub/action-types.yaml" ,
162
+ ),
163
+ -> hostedByActionYaml
164
+ else -> throw IOException ()
165
+ }
166
+ }
167
+ val actionCoord = ActionCoords (" some-owner" , " some-name/some-sub" , " v3" )
168
+
169
+ // When
170
+ val types = actionCoord.provideTypes(metadataRevision = CommitHash (" some-hash" ), fetchUri = fetchUri)
171
+
172
+ // Then
173
+ types shouldBe Pair (mapOf (" hosted-by-action-yaml" to StringTyping ), TypingActualSource .ACTION )
174
+ }
175
+
136
176
test(" only hosted by the action, both extensions" ) {
137
177
// Given
138
178
val fetchUri: (URI ) -> String = {
139
179
when (it) {
140
- URI (" https://raw.githubusercontent.com/some-owner/some-name/some-hash// action-types.yml" ) -> hostedByActionYml
141
- URI (" https://raw.githubusercontent.com/some-owner/some-name/some-hash// action-types.yaml" ) -> hostedByActionYaml
180
+ URI (" https://raw.githubusercontent.com/some-owner/some-name/some-hash/action-types.yml" ) -> hostedByActionYml
181
+ URI (" https://raw.githubusercontent.com/some-owner/some-name/some-hash/action-types.yaml" ) -> hostedByActionYaml
142
182
else -> throw IOException ()
143
183
}
144
184
}
@@ -151,13 +191,37 @@ class TypesProvidingTest :
151
191
types shouldBe Pair (mapOf (" hosted-by-action-yml" to StringTyping ), TypingActualSource .ACTION )
152
192
}
153
193
194
+ test(" only hosted by the subaction, both extensions" ) {
195
+ // Given
196
+ val fetchUri: (URI ) -> String = {
197
+ when (it) {
198
+ URI (
199
+ " https://raw.githubusercontent.com/some-owner/some-name/some-hash/some-sub/action-types.yml" ,
200
+ ),
201
+ -> hostedByActionYml
202
+ URI (
203
+ " https://raw.githubusercontent.com/some-owner/some-name/some-hash/some-sub/action-types.yaml" ,
204
+ ),
205
+ -> hostedByActionYaml
206
+ else -> throw IOException ()
207
+ }
208
+ }
209
+ val actionCoord = ActionCoords (" some-owner" , " some-name/some-sub" , " v3" )
210
+
211
+ // When
212
+ val types = actionCoord.provideTypes(metadataRevision = CommitHash (" some-hash" ), fetchUri = fetchUri)
213
+
214
+ // Then
215
+ types shouldBe Pair (mapOf (" hosted-by-action-yml" to StringTyping ), TypingActualSource .ACTION )
216
+ }
217
+
154
218
test(" only stored in typing catalog" ) {
155
219
// Given
156
220
val fetchUri: (URI ) -> String = {
157
221
when (it) {
158
222
URI (
159
223
" https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
160
- " main/typings/some-owner/some-name/v3// action-types.yml" ,
224
+ " main/typings/some-owner/some-name/v3/action-types.yml" ,
161
225
),
162
226
-> storedInTypingCatalog
163
227
else -> throw IOException ()
@@ -172,18 +236,39 @@ class TypesProvidingTest :
172
236
types shouldBe Pair (mapOf (" stored-in-typing-catalog" to StringTyping ), TypingActualSource .TYPING_CATALOG )
173
237
}
174
238
239
+ test(" only stored in typing catalog for subaction" ) {
240
+ // Given
241
+ val fetchUri: (URI ) -> String = {
242
+ when (it) {
243
+ URI (
244
+ " https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
245
+ " main/typings/some-owner/some-name/v3/some-sub/action-types.yml" ,
246
+ ),
247
+ -> storedInTypingCatalog
248
+ else -> throw IOException ()
249
+ }
250
+ }
251
+ val actionCoord = ActionCoords (" some-owner" , " some-name/some-sub" , " v3" )
252
+
253
+ // When
254
+ val types = actionCoord.provideTypes(metadataRevision = CommitHash (" some-hash" ), fetchUri = fetchUri)
255
+
256
+ // Then
257
+ types shouldBe Pair (mapOf (" stored-in-typing-catalog" to StringTyping ), TypingActualSource .TYPING_CATALOG )
258
+ }
259
+
175
260
test(" hosted by action and stored in typing catalog" ) {
176
261
// Given
177
262
val fetchUri: (URI ) -> String = {
178
263
when (it) {
179
264
URI (
180
265
" https://raw.githubusercontent.com/some-owner/some-name/" +
181
- " some-hash// action-types.yml" ,
266
+ " some-hash/action-types.yml" ,
182
267
),
183
268
-> hostedByActionYml
184
269
URI (
185
270
" https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
186
- " main/typings/some-owner/some-name/v3// action-types.yml" ,
271
+ " main/typings/some-owner/some-name/v3/action-types.yml" ,
187
272
),
188
273
-> storedInTypingCatalog
189
274
else -> throw IOException ()
@@ -198,6 +283,32 @@ class TypesProvidingTest :
198
283
types shouldBe Pair (mapOf (" hosted-by-action-yml" to StringTyping ), TypingActualSource .ACTION )
199
284
}
200
285
286
+ test(" hosted by subaction and stored in typing catalog" ) {
287
+ // Given
288
+ val fetchUri: (URI ) -> String = {
289
+ when (it) {
290
+ URI (
291
+ " https://raw.githubusercontent.com/some-owner/some-name/" +
292
+ " some-hash/some-sub/action-types.yml" ,
293
+ ),
294
+ -> hostedByActionYml
295
+ URI (
296
+ " https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
297
+ " main/typings/some-owner/some-name/v3/some-sub/action-types.yml" ,
298
+ ),
299
+ -> storedInTypingCatalog
300
+ else -> throw IOException ()
301
+ }
302
+ }
303
+ val actionCoord = ActionCoords (" some-owner" , " some-name/some-sub" , " v3" )
304
+
305
+ // When
306
+ val types = actionCoord.provideTypes(metadataRevision = CommitHash (" some-hash" ), fetchUri = fetchUri)
307
+
308
+ // Then
309
+ types shouldBe Pair (mapOf (" hosted-by-action-yml" to StringTyping ), TypingActualSource .ACTION )
310
+ }
311
+
201
312
test(" only stored in typing catalog for older version" ) {
202
313
// Given
203
314
val fetchUri: (URI ) -> String = {
@@ -209,7 +320,7 @@ class TypesProvidingTest :
209
320
-> metadata
210
321
URI (
211
322
" https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
212
- " main/typings/some-owner/some-name/v4// action-types.yml" ,
323
+ " main/typings/some-owner/some-name/v4/action-types.yml" ,
213
324
),
214
325
-> storedInTypingCatalogForOlderVersion
215
326
else -> throw IOException ()
@@ -224,6 +335,32 @@ class TypesProvidingTest :
224
335
types shouldBe Pair (mapOf (" stored-in-typing-catalog-for-older-version" to StringTyping ), TypingActualSource .TYPING_CATALOG )
225
336
}
226
337
338
+ test(" only stored in typing catalog for older version of subaction" ) {
339
+ // Given
340
+ val fetchUri: (URI ) -> String = {
341
+ when (it) {
342
+ URI (
343
+ " https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
344
+ " main/typings/some-owner/some-name/metadata.yml" ,
345
+ ),
346
+ -> metadata
347
+ URI (
348
+ " https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
349
+ " main/typings/some-owner/some-name/v4/some-sub/action-types.yml" ,
350
+ ),
351
+ -> storedInTypingCatalogForOlderVersion
352
+ else -> throw IOException ()
353
+ }
354
+ }
355
+ val actionCoord = ActionCoords (" some-owner" , " some-name/some-sub" , " v6" )
356
+
357
+ // When
358
+ val types = actionCoord.provideTypes(metadataRevision = CommitHash (" some-hash" ), fetchUri = fetchUri)
359
+
360
+ // Then
361
+ types shouldBe Pair (mapOf (" stored-in-typing-catalog-for-older-version" to StringTyping ), TypingActualSource .TYPING_CATALOG )
362
+ }
363
+
227
364
test(" metadata available but no version available" ) {
228
365
// Given
229
366
val fetchUri: (URI ) -> String = {
@@ -288,7 +425,7 @@ class TypesProvidingTest :
288
425
// Given
289
426
val fetchUri: (URI ) -> String = {
290
427
when (it) {
291
- URI (" https://raw.githubusercontent.com/some-owner/some-name/some-hash// action-types.yml" ) -> typingYml
428
+ URI (" https://raw.githubusercontent.com/some-owner/some-name/some-hash/action-types.yml" ) -> typingYml
292
429
else -> throw IOException ()
293
430
}
294
431
}
@@ -315,7 +452,7 @@ class TypesProvidingTest :
315
452
when (it) {
316
453
URI (
317
454
" https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
318
- " main/typings/some-owner/some-name/v3// action-types.yml" ,
455
+ " main/typings/some-owner/some-name/v3/action-types.yml" ,
319
456
),
320
457
-> typingYml
321
458
else -> throw IOException ()
@@ -349,7 +486,7 @@ class TypesProvidingTest :
349
486
-> metadata
350
487
URI (
351
488
" https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
352
- " main/typings/some-owner/some-name/v4// action-types.yml" ,
489
+ " main/typings/some-owner/some-name/v4/action-types.yml" ,
353
490
),
354
491
-> typingYml
355
492
else -> throw IOException ()
0 commit comments