Skip to content

Commit fbb1aa3

Browse files
authored
test(abg): specify typing in generation test (#1594)
Part of #1585. It's needed because without this change, the generator infers there are no typings for these test actions (the actions actually don't exist), and in the new world it would only produce the `_Untyped` binding for them. These tests actually check the path where the typings are provided. For simplicity, we use `String` everywhere because there's already a test that checks generation for other typings.
1 parent 0a0c013 commit fbb1aa3

1 file changed

Lines changed: 39 additions & 6 deletions

File tree

  • action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation

action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/GenerationTest.kt

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import io.github.typesafegithub.workflows.actionbindinggenerator.typing.IntegerT
1414
import io.github.typesafegithub.workflows.actionbindinggenerator.typing.IntegerWithSpecialValueTyping
1515
import io.github.typesafegithub.workflows.actionbindinggenerator.typing.ListOfTypings
1616
import io.github.typesafegithub.workflows.actionbindinggenerator.typing.StringTyping
17+
import io.github.typesafegithub.workflows.actionbindinggenerator.typing.Typing
1718
import io.kotest.core.spec.style.FunSpec
1819

1920
class GenerationTest :
@@ -139,7 +140,12 @@ class GenerationTest :
139140
val coords = ActionCoords("john-smith", "simple-action-with-required-string-inputs", "v3")
140141

141142
// when
142-
val binding = coords.generateBinding(metadataRevision = NewestForVersion, metadata = actionManifest)
143+
val binding =
144+
coords.generateBinding(
145+
metadataRevision = NewestForVersion,
146+
metadata = actionManifest,
147+
inputTypings = Pair(actionManifest.allInputsAsStrings(), ACTION),
148+
)
143149

144150
// then
145151
binding.shouldContainAndMatchFile("SimpleActionWithRequiredStringInputs.kt")
@@ -184,7 +190,12 @@ class GenerationTest :
184190
val coords = ActionCoords("john-smith", "action-with-some-optional-inputs", "v3")
185191

186192
// when
187-
val binding = coords.generateBinding(metadataRevision = NewestForVersion, metadata = actionManifest)
193+
val binding =
194+
coords.generateBinding(
195+
metadataRevision = NewestForVersion,
196+
metadata = actionManifest,
197+
inputTypings = Pair(actionManifest.allInputsAsStrings(), ACTION),
198+
)
188199

189200
// then
190201
binding.shouldContainAndMatchFile("ActionWithSomeOptionalInputs.kt")
@@ -234,7 +245,12 @@ class GenerationTest :
234245
val coords = ActionCoords("john-smith", "action-with-outputs", "v3")
235246

236247
// when
237-
val binding = coords.generateBinding(metadataRevision = NewestForVersion, metadata = actionManifest)
248+
val binding =
249+
coords.generateBinding(
250+
metadataRevision = NewestForVersion,
251+
metadata = actionManifest,
252+
inputTypings = Pair(actionManifest.allInputsAsStrings(), ACTION),
253+
)
238254

239255
// then
240256
binding.shouldContainAndMatchFile("ActionWithOutputs.kt")
@@ -253,7 +269,12 @@ class GenerationTest :
253269
val coords = ActionCoords("john-smith", "action-with-no-inputs", "v3")
254270

255271
// when
256-
val binding = coords.generateBinding(metadataRevision = NewestForVersion, metadata = actionManifest)
272+
val binding =
273+
coords.generateBinding(
274+
metadataRevision = NewestForVersion,
275+
metadata = actionManifest,
276+
inputTypings = Pair(emptyMap(), ACTION),
277+
)
257278

258279
// then
259280
binding.shouldContainAndMatchFile("ActionWithNoInputs.kt")
@@ -286,7 +307,12 @@ class GenerationTest :
286307
val coords = ActionCoords("john-smith", "action-with-deprecated-input-and-name-clash", "v2")
287308

288309
// when
289-
val binding = coords.generateBinding(metadataRevision = NewestForVersion, metadata = actionManifest)
310+
val binding =
311+
coords.generateBinding(
312+
metadataRevision = NewestForVersion,
313+
metadata = actionManifest,
314+
inputTypings = Pair(actionManifest.allInputsAsStrings(), ACTION),
315+
)
290316

291317
// then
292318
binding.shouldContainAndMatchFile("ActionWithDeprecatedInputAndNameClash.kt")
@@ -360,9 +386,16 @@ class GenerationTest :
360386
val coords = ActionCoords("john-smith", "action-with-fancy-chars-in-docs", "v3")
361387

362388
// when
363-
val binding = coords.generateBinding(metadataRevision = NewestForVersion, metadata = actionManifest)
389+
val binding =
390+
coords.generateBinding(
391+
metadataRevision = NewestForVersion,
392+
metadata = actionManifest,
393+
inputTypings = Pair(actionManifest.allInputsAsStrings(), ACTION),
394+
)
364395

365396
// then
366397
binding.shouldContainAndMatchFile("ActionWithFancyCharsInDocs.kt")
367398
}
368399
})
400+
401+
private fun Metadata.allInputsAsStrings(): Map<String, Typing> = this.inputs.mapValues { StringTyping }

0 commit comments

Comments
 (0)