Skip to content

Commit abcd2d6

Browse files
authored
test(abg): move expected code for JAR to file (#1331)
Part of #1318. Thanks to this, it will also be tested if it's compilable. We can move it because, unlikely to the test that checks the script-specific generation, the file generated here is not meant to be used in a script.
1 parent 6ccc9b8 commit abcd2d6

File tree

2 files changed

+91
-95
lines changed

2 files changed

+91
-95
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// This file was generated using action-binding-generator. Don't change it by hand, otherwise your
2+
// changes will be overwritten with the next binding code regeneration.
3+
// See https://github.com/typesafegithub/github-workflows-kt for more info.
4+
@file:Suppress(
5+
"DataClassPrivateConstructor",
6+
"UNUSED_PARAMETER",
7+
"DEPRECATION",
8+
)
9+
10+
package io.github.typesafegithub.workflows.actions.johnsmith
11+
12+
import io.github.typesafegithub.workflows.domain.actions.Action
13+
import io.github.typesafegithub.workflows.domain.actions.RegularAction
14+
import java.util.LinkedHashMap
15+
import kotlin.Deprecated
16+
import kotlin.String
17+
import kotlin.Suppress
18+
import kotlin.Unit
19+
import kotlin.collections.Map
20+
import kotlin.collections.toList
21+
import kotlin.collections.toTypedArray
22+
23+
/**
24+
* Action: Do something cool
25+
* and describe it in multiple lines
26+
*
27+
* This is a test description that should be put in the KDoc comment for a class
28+
*
29+
* [Action on GitHub](https://github.com/john-smith/action-for-generated-jar)
30+
*
31+
* @param fooBar Short description
32+
* @param bazGoo Just another input
33+
* with multiline description
34+
* @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported by
35+
* the binding
36+
* @param _customVersion Allows overriding action's version, for example to use a specific minor
37+
* version, or a newer version that the binding doesn't yet know about
38+
*/
39+
public data class ActionForGeneratedJar private constructor(
40+
/**
41+
* Short description
42+
*/
43+
public val fooBar: String,
44+
/**
45+
* Just another input
46+
* with multiline description
47+
*/
48+
@Deprecated("this is deprecated")
49+
public val bazGoo: ActionForGeneratedJar.BazGoo,
50+
/**
51+
* Type-unsafe map where you can put any inputs that are not yet supported by the binding
52+
*/
53+
public val _customInputs: Map<String, String> = mapOf(),
54+
/**
55+
* Allows overriding action's version, for example to use a specific minor version, or a newer
56+
* version that the binding doesn't yet know about
57+
*/
58+
public val _customVersion: String? = null,
59+
) : RegularAction<Action.Outputs>("john-smith", "action-for-generated-jar", _customVersion ?: "v3")
60+
{
61+
public constructor(
62+
vararg pleaseUseNamedArguments: Unit,
63+
fooBar: String,
64+
bazGoo: ActionForGeneratedJar.BazGoo,
65+
_customInputs: Map<String, String> = mapOf(),
66+
_customVersion: String? = null,
67+
) : this(fooBar=fooBar, bazGoo=bazGoo, _customInputs=_customInputs,
68+
_customVersion=_customVersion)
69+
70+
@Suppress("SpreadOperator")
71+
override fun toYamlArguments(): LinkedHashMap<String, String> = linkedMapOf(
72+
*listOfNotNull(
73+
"foo-bar" to fooBar,
74+
"baz-goo" to bazGoo.stringValue,
75+
*_customInputs.toList().toTypedArray(),
76+
).toTypedArray()
77+
)
78+
79+
override fun buildOutputObject(stepId: String): Action.Outputs = Outputs(stepId)
80+
81+
public sealed class BazGoo(
82+
public val stringValue: String,
83+
) {
84+
public object HelloWorld : ActionForGeneratedJar.BazGoo("helloworld")
85+
86+
public class Custom(
87+
customStringValue: String,
88+
) : ActionForGeneratedJar.BazGoo(customStringValue)
89+
}
90+
}

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

Lines changed: 1 addition & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -582,100 +582,6 @@ class GenerationTest : FunSpec({
582582
)
583583

584584
// then
585-
//language=kotlin
586-
binding.kotlinCode shouldBe
587-
"""
588-
// This file was generated using action-binding-generator. Don't change it by hand, otherwise your
589-
// changes will be overwritten with the next binding code regeneration.
590-
// See https://github.com/typesafegithub/github-workflows-kt for more info.
591-
@file:Suppress(
592-
"DataClassPrivateConstructor",
593-
"UNUSED_PARAMETER",
594-
"DEPRECATION",
595-
)
596-
597-
package io.github.typesafegithub.workflows.actions.johnsmith
598-
599-
import io.github.typesafegithub.workflows.domain.actions.Action
600-
import io.github.typesafegithub.workflows.domain.actions.RegularAction
601-
import java.util.LinkedHashMap
602-
import kotlin.Deprecated
603-
import kotlin.String
604-
import kotlin.Suppress
605-
import kotlin.Unit
606-
import kotlin.collections.Map
607-
import kotlin.collections.toList
608-
import kotlin.collections.toTypedArray
609-
610-
/**
611-
* Action: Do something cool
612-
* and describe it in multiple lines
613-
*
614-
* This is a test description that should be put in the KDoc comment for a class
615-
*
616-
* [Action on GitHub](https://github.com/john-smith/action-for-generated-jar)
617-
*
618-
* @param fooBar Short description
619-
* @param bazGoo Just another input
620-
* with multiline description
621-
* @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported by
622-
* the binding
623-
* @param _customVersion Allows overriding action's version, for example to use a specific minor
624-
* version, or a newer version that the binding doesn't yet know about
625-
*/
626-
public data class ActionForGeneratedJar private constructor(
627-
/**
628-
* Short description
629-
*/
630-
public val fooBar: String,
631-
/**
632-
* Just another input
633-
* with multiline description
634-
*/
635-
@Deprecated("this is deprecated")
636-
public val bazGoo: ActionForGeneratedJar.BazGoo,
637-
/**
638-
* Type-unsafe map where you can put any inputs that are not yet supported by the binding
639-
*/
640-
public val _customInputs: Map<String, String> = mapOf(),
641-
/**
642-
* Allows overriding action's version, for example to use a specific minor version, or a newer
643-
* version that the binding doesn't yet know about
644-
*/
645-
public val _customVersion: String? = null,
646-
) : RegularAction<Action.Outputs>("john-smith", "action-for-generated-jar", _customVersion ?: "v3")
647-
{
648-
public constructor(
649-
vararg pleaseUseNamedArguments: Unit,
650-
fooBar: String,
651-
bazGoo: ActionForGeneratedJar.BazGoo,
652-
_customInputs: Map<String, String> = mapOf(),
653-
_customVersion: String? = null,
654-
) : this(fooBar=fooBar, bazGoo=bazGoo, _customInputs=_customInputs,
655-
_customVersion=_customVersion)
656-
657-
@Suppress("SpreadOperator")
658-
override fun toYamlArguments(): LinkedHashMap<String, String> = linkedMapOf(
659-
*listOfNotNull(
660-
"foo-bar" to fooBar,
661-
"baz-goo" to bazGoo.stringValue,
662-
*_customInputs.toList().toTypedArray(),
663-
).toTypedArray()
664-
)
665-
666-
override fun buildOutputObject(stepId: String): Action.Outputs = Outputs(stepId)
667-
668-
public sealed class BazGoo(
669-
public val stringValue: String,
670-
) {
671-
public object HelloWorld : ActionForGeneratedJar.BazGoo("helloworld")
672-
673-
public class Custom(
674-
customStringValue: String,
675-
) : ActionForGeneratedJar.BazGoo(customStringValue)
676-
}
677-
}
678-
679-
""".trimIndent()
585+
binding.shouldMatchFile("ActionForGeneratedJar.kt")
680586
}
681587
})

0 commit comments

Comments
 (0)