@@ -103,7 +103,7 @@ class TypesProvidingTest :
103103 // Given
104104 val fetchUri: (URI ) -> String = {
105105 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
107107 else -> throw IOException ()
108108 }
109109 }
@@ -116,11 +116,31 @@ class TypesProvidingTest :
116116 types shouldBe Pair (mapOf (" hosted-by-action-yml" to StringTyping ), TypingActualSource .ACTION )
117117 }
118118
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+
119139 test(" only hosted by the action (.yaml)" ) {
120140 // Given
121141 val fetchUri: (URI ) -> String = {
122142 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
124144 else -> throw IOException ()
125145 }
126146 }
@@ -133,12 +153,32 @@ class TypesProvidingTest :
133153 types shouldBe Pair (mapOf (" hosted-by-action-yaml" to StringTyping ), TypingActualSource .ACTION )
134154 }
135155
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+
136176 test(" only hosted by the action, both extensions" ) {
137177 // Given
138178 val fetchUri: (URI ) -> String = {
139179 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
142182 else -> throw IOException ()
143183 }
144184 }
@@ -151,13 +191,37 @@ class TypesProvidingTest :
151191 types shouldBe Pair (mapOf (" hosted-by-action-yml" to StringTyping ), TypingActualSource .ACTION )
152192 }
153193
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+
154218 test(" only stored in typing catalog" ) {
155219 // Given
156220 val fetchUri: (URI ) -> String = {
157221 when (it) {
158222 URI (
159223 " 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" ,
161225 ),
162226 -> storedInTypingCatalog
163227 else -> throw IOException ()
@@ -172,18 +236,39 @@ class TypesProvidingTest :
172236 types shouldBe Pair (mapOf (" stored-in-typing-catalog" to StringTyping ), TypingActualSource .TYPING_CATALOG )
173237 }
174238
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+
175260 test(" hosted by action and stored in typing catalog" ) {
176261 // Given
177262 val fetchUri: (URI ) -> String = {
178263 when (it) {
179264 URI (
180265 " https://raw.githubusercontent.com/some-owner/some-name/" +
181- " some-hash// action-types.yml" ,
266+ " some-hash/action-types.yml" ,
182267 ),
183268 -> hostedByActionYml
184269 URI (
185270 " 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" ,
187272 ),
188273 -> storedInTypingCatalog
189274 else -> throw IOException ()
@@ -198,6 +283,32 @@ class TypesProvidingTest :
198283 types shouldBe Pair (mapOf (" hosted-by-action-yml" to StringTyping ), TypingActualSource .ACTION )
199284 }
200285
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+
201312 test(" only stored in typing catalog for older version" ) {
202313 // Given
203314 val fetchUri: (URI ) -> String = {
@@ -209,7 +320,7 @@ class TypesProvidingTest :
209320 -> metadata
210321 URI (
211322 " 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" ,
213324 ),
214325 -> storedInTypingCatalogForOlderVersion
215326 else -> throw IOException ()
@@ -224,6 +335,32 @@ class TypesProvidingTest :
224335 types shouldBe Pair (mapOf (" stored-in-typing-catalog-for-older-version" to StringTyping ), TypingActualSource .TYPING_CATALOG )
225336 }
226337
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+
227364 test(" metadata available but no version available" ) {
228365 // Given
229366 val fetchUri: (URI ) -> String = {
@@ -288,7 +425,7 @@ class TypesProvidingTest :
288425 // Given
289426 val fetchUri: (URI ) -> String = {
290427 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
292429 else -> throw IOException ()
293430 }
294431 }
@@ -315,7 +452,7 @@ class TypesProvidingTest :
315452 when (it) {
316453 URI (
317454 " 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" ,
319456 ),
320457 -> typingYml
321458 else -> throw IOException ()
@@ -349,7 +486,7 @@ class TypesProvidingTest :
349486 -> metadata
350487 URI (
351488 " 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" ,
353490 ),
354491 -> typingYml
355492 else -> throw IOException ()
0 commit comments