@@ -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,28 @@ 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 (" https://raw.githubusercontent.com/some-owner/some-name/some-hash/some-sub/action-types.yml" ) -> hostedByActionYml
124
+ else -> throw IOException ()
125
+ }
126
+ }
127
+ val actionCoord = ActionCoords (" some-owner" , " some-name/some-sub" , " v3" )
128
+
129
+ // When
130
+ val types = actionCoord.provideTypes(metadataRevision = CommitHash (" some-hash" ), fetchUri = fetchUri)
131
+
132
+ // Then
133
+ types shouldBe Pair (mapOf (" hosted-by-action-yml" to StringTyping ), TypingActualSource .ACTION )
134
+ }
135
+
119
136
test(" only hosted by the action (.yaml)" ) {
120
137
// Given
121
138
val fetchUri: (URI ) -> String = {
122
139
when (it) {
123
- URI (" https://raw.githubusercontent.com/some-owner/some-name/some-hash// action-types.yaml" ) -> hostedByActionYaml
140
+ URI (" https://raw.githubusercontent.com/some-owner/some-name/some-hash/action-types.yaml" ) -> hostedByActionYaml
124
141
else -> throw IOException ()
125
142
}
126
143
}
@@ -133,12 +150,29 @@ class TypesProvidingTest :
133
150
types shouldBe Pair (mapOf (" hosted-by-action-yaml" to StringTyping ), TypingActualSource .ACTION )
134
151
}
135
152
153
+ test(" only hosted by the subaction (.yaml)" ) {
154
+ // Given
155
+ val fetchUri: (URI ) -> String = {
156
+ when (it) {
157
+ URI (" https://raw.githubusercontent.com/some-owner/some-name/some-hash/some-sub/action-types.yaml" ) -> hostedByActionYaml
158
+ else -> throw IOException ()
159
+ }
160
+ }
161
+ val actionCoord = ActionCoords (" some-owner" , " some-name/some-sub" , " v3" )
162
+
163
+ // When
164
+ val types = actionCoord.provideTypes(metadataRevision = CommitHash (" some-hash" ), fetchUri = fetchUri)
165
+
166
+ // Then
167
+ types shouldBe Pair (mapOf (" hosted-by-action-yaml" to StringTyping ), TypingActualSource .ACTION )
168
+ }
169
+
136
170
test(" only hosted by the action, both extensions" ) {
137
171
// Given
138
172
val fetchUri: (URI ) -> String = {
139
173
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
174
+ URI (" https://raw.githubusercontent.com/some-owner/some-name/some-hash/action-types.yml" ) -> hostedByActionYml
175
+ URI (" https://raw.githubusercontent.com/some-owner/some-name/some-hash/action-types.yaml" ) -> hostedByActionYaml
142
176
else -> throw IOException ()
143
177
}
144
178
}
@@ -151,13 +185,31 @@ class TypesProvidingTest :
151
185
types shouldBe Pair (mapOf (" hosted-by-action-yml" to StringTyping ), TypingActualSource .ACTION )
152
186
}
153
187
188
+ test(" only hosted by the subaction, both extensions" ) {
189
+ // Given
190
+ val fetchUri: (URI ) -> String = {
191
+ when (it) {
192
+ URI (" https://raw.githubusercontent.com/some-owner/some-name/some-hash/some-sub/action-types.yml" ) -> hostedByActionYml
193
+ URI (" https://raw.githubusercontent.com/some-owner/some-name/some-hash/some-sub/action-types.yaml" ) -> hostedByActionYaml
194
+ else -> throw IOException ()
195
+ }
196
+ }
197
+ val actionCoord = ActionCoords (" some-owner" , " some-name/some-sub" , " v3" )
198
+
199
+ // When
200
+ val types = actionCoord.provideTypes(metadataRevision = CommitHash (" some-hash" ), fetchUri = fetchUri)
201
+
202
+ // Then
203
+ types shouldBe Pair (mapOf (" hosted-by-action-yml" to StringTyping ), TypingActualSource .ACTION )
204
+ }
205
+
154
206
test(" only stored in typing catalog" ) {
155
207
// Given
156
208
val fetchUri: (URI ) -> String = {
157
209
when (it) {
158
210
URI (
159
211
" https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
160
- " main/typings/some-owner/some-name/v3// action-types.yml" ,
212
+ " main/typings/some-owner/some-name/v3/action-types.yml" ,
161
213
),
162
214
-> storedInTypingCatalog
163
215
else -> throw IOException ()
@@ -172,18 +224,39 @@ class TypesProvidingTest :
172
224
types shouldBe Pair (mapOf (" stored-in-typing-catalog" to StringTyping ), TypingActualSource .TYPING_CATALOG )
173
225
}
174
226
227
+ test(" only stored in typing catalog for subaction" ) {
228
+ // Given
229
+ val fetchUri: (URI ) -> String = {
230
+ when (it) {
231
+ URI (
232
+ " https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
233
+ " main/typings/some-owner/some-name/v3/some-sub/action-types.yml" ,
234
+ ),
235
+ -> storedInTypingCatalog
236
+ else -> throw IOException ()
237
+ }
238
+ }
239
+ val actionCoord = ActionCoords (" some-owner" , " some-name/some-sub" , " v3" )
240
+
241
+ // When
242
+ val types = actionCoord.provideTypes(metadataRevision = CommitHash (" some-hash" ), fetchUri = fetchUri)
243
+
244
+ // Then
245
+ types shouldBe Pair (mapOf (" stored-in-typing-catalog" to StringTyping ), TypingActualSource .TYPING_CATALOG )
246
+ }
247
+
175
248
test(" hosted by action and stored in typing catalog" ) {
176
249
// Given
177
250
val fetchUri: (URI ) -> String = {
178
251
when (it) {
179
252
URI (
180
253
" https://raw.githubusercontent.com/some-owner/some-name/" +
181
- " some-hash// action-types.yml" ,
254
+ " some-hash/action-types.yml" ,
182
255
),
183
256
-> hostedByActionYml
184
257
URI (
185
258
" https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
186
- " main/typings/some-owner/some-name/v3// action-types.yml" ,
259
+ " main/typings/some-owner/some-name/v3/action-types.yml" ,
187
260
),
188
261
-> storedInTypingCatalog
189
262
else -> throw IOException ()
@@ -198,6 +271,32 @@ class TypesProvidingTest :
198
271
types shouldBe Pair (mapOf (" hosted-by-action-yml" to StringTyping ), TypingActualSource .ACTION )
199
272
}
200
273
274
+ test(" hosted by subaction and stored in typing catalog" ) {
275
+ // Given
276
+ val fetchUri: (URI ) -> String = {
277
+ when (it) {
278
+ URI (
279
+ " https://raw.githubusercontent.com/some-owner/some-name/" +
280
+ " some-hash/some-sub/action-types.yml" ,
281
+ ),
282
+ -> hostedByActionYml
283
+ URI (
284
+ " https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
285
+ " main/typings/some-owner/some-name/v3/some-sub/action-types.yml" ,
286
+ ),
287
+ -> storedInTypingCatalog
288
+ else -> throw IOException ()
289
+ }
290
+ }
291
+ val actionCoord = ActionCoords (" some-owner" , " some-name/some-sub" , " v3" )
292
+
293
+ // When
294
+ val types = actionCoord.provideTypes(metadataRevision = CommitHash (" some-hash" ), fetchUri = fetchUri)
295
+
296
+ // Then
297
+ types shouldBe Pair (mapOf (" hosted-by-action-yml" to StringTyping ), TypingActualSource .ACTION )
298
+ }
299
+
201
300
test(" only stored in typing catalog for older version" ) {
202
301
// Given
203
302
val fetchUri: (URI ) -> String = {
@@ -209,7 +308,7 @@ class TypesProvidingTest :
209
308
-> metadata
210
309
URI (
211
310
" https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
212
- " main/typings/some-owner/some-name/v4// action-types.yml" ,
311
+ " main/typings/some-owner/some-name/v4/action-types.yml" ,
213
312
),
214
313
-> storedInTypingCatalogForOlderVersion
215
314
else -> throw IOException ()
@@ -224,6 +323,32 @@ class TypesProvidingTest :
224
323
types shouldBe Pair (mapOf (" stored-in-typing-catalog-for-older-version" to StringTyping ), TypingActualSource .TYPING_CATALOG )
225
324
}
226
325
326
+ test(" only stored in typing catalog for older version of subaction" ) {
327
+ // Given
328
+ val fetchUri: (URI ) -> String = {
329
+ when (it) {
330
+ URI (
331
+ " https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
332
+ " main/typings/some-owner/some-name/metadata.yml" ,
333
+ ),
334
+ -> metadata
335
+ URI (
336
+ " https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
337
+ " main/typings/some-owner/some-name/v4/some-sub/action-types.yml" ,
338
+ ),
339
+ -> storedInTypingCatalogForOlderVersion
340
+ else -> throw IOException ()
341
+ }
342
+ }
343
+ val actionCoord = ActionCoords (" some-owner" , " some-name/some-sub" , " v6" )
344
+
345
+ // When
346
+ val types = actionCoord.provideTypes(metadataRevision = CommitHash (" some-hash" ), fetchUri = fetchUri)
347
+
348
+ // Then
349
+ types shouldBe Pair (mapOf (" stored-in-typing-catalog-for-older-version" to StringTyping ), TypingActualSource .TYPING_CATALOG )
350
+ }
351
+
227
352
test(" metadata available but no version available" ) {
228
353
// Given
229
354
val fetchUri: (URI ) -> String = {
0 commit comments