File tree Expand file tree Collapse file tree
github-workflows-kt/src/test/kotlin/io/github/typesafegithub/workflows/domain Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,19 +7,19 @@ import io.ktor.client.statement.bodyAsText
77/* *
88 * Lists values allowed to be set in "runs-on" for a job, for GitHub-hosted runners.
99 */
10- suspend fun listRunnerLabels (): List <String > {
10+ suspend fun listRunnerLabels (): Set <String > {
1111 val html = HttpClient ().get(GITHUB_RUNNER_LABELS_DOCS_URL ).bodyAsText()
1212 return parse(html)
1313}
1414
1515private const val GITHUB_RUNNER_LABELS_DOCS_URL : String =
1616 " https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions"
1717
18- private fun parse (html : String ): List <String > =
18+ private fun parse (html : String ): Set <String > =
1919 RUNNER_LABEL_REGEX
2020 .findAll(html)
2121 .map { it.groupValues[1 ] }
22- .toList ()
22+ .toSet ()
2323
2424private val RUNNER_LABEL_REGEX =
2525 Regex (
Original file line number Diff line number Diff line change 11package io.github.typesafegithub.workflows.domain
22
3+ import io.kotest.assertions.assertSoftly
34import io.kotest.assertions.throwables.shouldThrow
5+ import io.kotest.assertions.withClue
46import io.kotest.core.spec.style.FunSpec
7+ import io.kotest.matchers.shouldBe
58
69class RunnerTypeTest :
710 FunSpec ({
11+ test(" all supported runner labels should correspond to lib's classes" ) {
12+ val fromLib =
13+ RunnerType .GitHubHosted ::class
14+ .sealedSubclasses
15+ .mapNotNull { it.objectInstance?.value }
16+ .toSet()
17+ val fromDocs = listRunnerLabels().toSet()
18+
19+ assertSoftly {
20+ withClue(" no obsolete labels are in the lib" ) {
21+ fromLib - fromDocs shouldBe emptySet<String >()
22+ }
23+
24+ withClue(" no missing labels are in the lib" ) {
25+ fromDocs - fromLib shouldBe emptySet<String >()
26+ }
27+ }
28+ }
29+
830 context(" Labelled" ) {
931 test(" should throw on invalid arguments" ) {
1032 shouldThrow<IllegalArgumentException > {
You can’t perform that action at this time.
0 commit comments