Skip to content

Commit a18562f

Browse files
authored
test(abg): extract metadata and typings for all types of inputs (#1334)
To be able to reuse it easily.
1 parent 29562ba commit a18562f

File tree

1 file changed

+85
-82
lines changed
  • action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation

1 file changed

+85
-82
lines changed

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

Lines changed: 85 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,89 @@ import io.kotest.core.spec.style.FunSpec
1818
import io.kotest.matchers.shouldBe
1919

2020
class GenerationTest : FunSpec({
21+
val actionManifestWithAllTypesOfInputs =
22+
Metadata(
23+
name = "Do something cool",
24+
description = "This is a test description that should be put in the KDoc comment for a class",
25+
inputs =
26+
mapOf(
27+
"foo-bar" to
28+
Input(
29+
description = "Short description",
30+
required = true,
31+
default = null,
32+
),
33+
"baz-goo" to
34+
Input(
35+
description = "First boolean input!",
36+
required = true,
37+
default = null,
38+
),
39+
"bin-kin" to
40+
Input(
41+
description = "Boolean and nullable",
42+
required = false,
43+
default = "test",
44+
),
45+
"int-pint" to
46+
Input(
47+
description = "Integer",
48+
required = true,
49+
default = null,
50+
),
51+
"flo-pint" to
52+
Input(
53+
description = "Float",
54+
required = true,
55+
default = null,
56+
),
57+
"fin-bin" to
58+
Input(
59+
description = "Enumeration",
60+
required = true,
61+
default = null,
62+
),
63+
"goo-zen" to
64+
Input(
65+
description = "Integer with special value",
66+
required = true,
67+
default = null,
68+
),
69+
"bah-enum" to
70+
Input(
71+
description = "Enum with custom naming",
72+
required = true,
73+
default = null,
74+
),
75+
"list-strings" to Input("List of strings"),
76+
"list-ints" to Input("List of integers"),
77+
"list-enums" to Input("List of enums"),
78+
"list-int-special" to Input("List of integer with special values"),
79+
),
80+
)
81+
val typingsForAllTypesOfInputs =
82+
mapOf(
83+
"baz-goo" to BooleanTyping,
84+
"bin-kin" to BooleanTyping,
85+
"int-pint" to IntegerTyping,
86+
"flo-pint" to FloatTyping,
87+
"fin-bin" to EnumTyping("Bin", listOf("foo", "boo-bar", "baz123")),
88+
"goo-zen" to IntegerWithSpecialValueTyping("Zen", mapOf("Special1" to 3, "Special2" to -1)),
89+
"bah-enum" to EnumTyping(null, listOf("helloworld"), listOf("HelloWorld")),
90+
"list-strings" to ListOfTypings(",", StringTyping),
91+
"list-ints" to ListOfTypings(",", IntegerTyping),
92+
"list-enums" to
93+
ListOfTypings(
94+
delimiter = ",",
95+
typing = EnumTyping("MyEnum", listOf("one", "two", "three")),
96+
),
97+
"list-int-special" to
98+
ListOfTypings(
99+
delimiter = ",",
100+
typing = IntegerWithSpecialValueTyping("MyInt", mapOf("the-answer" to 42)),
101+
),
102+
)
103+
21104
test("action with required inputs as strings, no outputs") {
22105
// given
23106
val actionManifest =
@@ -105,96 +188,16 @@ class GenerationTest : FunSpec({
105188

106189
test("action with all types of inputs") {
107190
// given
108-
val actionManifest =
109-
Metadata(
110-
name = "Do something cool",
111-
description = "This is a test description that should be put in the KDoc comment for a class",
112-
inputs =
113-
mapOf(
114-
"foo-bar" to
115-
Input(
116-
description = "Short description",
117-
required = true,
118-
default = null,
119-
),
120-
"baz-goo" to
121-
Input(
122-
description = "First boolean input!",
123-
required = true,
124-
default = null,
125-
),
126-
"bin-kin" to
127-
Input(
128-
description = "Boolean and nullable",
129-
required = false,
130-
default = "test",
131-
),
132-
"int-pint" to
133-
Input(
134-
description = "Integer",
135-
required = true,
136-
default = null,
137-
),
138-
"flo-pint" to
139-
Input(
140-
description = "Float",
141-
required = true,
142-
default = null,
143-
),
144-
"fin-bin" to
145-
Input(
146-
description = "Enumeration",
147-
required = true,
148-
default = null,
149-
),
150-
"goo-zen" to
151-
Input(
152-
description = "Integer with special value",
153-
required = true,
154-
default = null,
155-
),
156-
"bah-enum" to
157-
Input(
158-
description = "Enum with custom naming",
159-
required = true,
160-
default = null,
161-
),
162-
"list-strings" to Input("List of strings"),
163-
"list-ints" to Input("List of integers"),
164-
"list-enums" to Input("List of enums"),
165-
"list-int-special" to Input("List of integer with special values"),
166-
),
167-
)
168191
val coords = ActionCoords("john-smith", "action-with-all-types-of-inputs", "v3")
169192

170193
// when
171194
val binding =
172195
coords.generateBinding(
173196
metadataRevision = FromLockfile,
174-
metadata = actionManifest,
197+
metadata = actionManifestWithAllTypesOfInputs,
175198
inputTypings =
176199
Pair(
177-
mapOf(
178-
"baz-goo" to BooleanTyping,
179-
"bin-kin" to BooleanTyping,
180-
"int-pint" to IntegerTyping,
181-
"flo-pint" to FloatTyping,
182-
"fin-bin" to EnumTyping("Bin", listOf("foo", "boo-bar", "baz123")),
183-
"goo-zen" to IntegerWithSpecialValueTyping("Zen", mapOf("Special1" to 3, "Special2" to -1)),
184-
"bah-enum" to EnumTyping(null, listOf("helloworld"), listOf("HelloWorld")),
185-
"list-strings" to ListOfTypings(",", StringTyping),
186-
"list-ints" to ListOfTypings(",", IntegerTyping),
187-
"list-enums" to
188-
ListOfTypings(
189-
delimiter = ",",
190-
typing = EnumTyping("MyEnum", listOf("one", "two", "three")),
191-
),
192-
"list-int-special" to
193-
ListOfTypings(
194-
delimiter = ",",
195-
typing = IntegerWithSpecialValueTyping("MyInt", mapOf("the-answer" to 42)),
196-
),
197-
),
200+
typingsForAllTypesOfInputs,
198201
ACTION,
199202
),
200203
)

0 commit comments

Comments
 (0)