Skip to content

Commit

Permalink
[#22] fix: allow empty types YAML
Browse files Browse the repository at this point in the history
Ideally we'd like to support also something like:

```yaml
types:
```

but there's a problem with the YAML parser that I'm going to clarify as
a follow-up.
  • Loading branch information
krzema12 committed Jul 22, 2022
1 parent fa29dd5 commit b8c09e5
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
@@ -1,14 +1,19 @@
package it.krzeminski.githubactionstyping

import it.krzeminski.githubactionstyping.github.getBooleanInput
import it.krzeminski.githubactionstyping.parsing.TypesManifest
import it.krzeminski.githubactionstyping.parsing.parseManifest
import it.krzeminski.githubactionstyping.parsing.parseTypesManifest
import it.krzeminski.githubactionstyping.reporting.toPlaintextReport
import it.krzeminski.githubactionstyping.validation.ItemValidationResult
import it.krzeminski.githubactionstyping.validation.validate

fun manifestsToReport(manifest: String, typesManifest: String): Pair<Boolean, String> {
val parsedTypesManifest = parseTypesManifest(typesManifest)
val parsedTypesManifest = if (typesManifest.isNotBlank()) {
parseTypesManifest(typesManifest)
} else {
TypesManifest()
}
val parsedManifest = parseManifest(manifest)

val inputsInTypesManifest = parsedTypesManifest.inputs.keys
Expand Down
Expand Up @@ -120,6 +120,39 @@ class ManifestsToReportTest : FunSpec({
}
}

test("blank types YAML") {
// when
val manifest = """
name: GitHub Actions Typing
description: Bring type-safety to your GitHub actions' API!
author: Piotr Krzemiński
runs:
using: 'docker'
image: 'Dockerfile'
""".trimIndent()
val typesManifest = " "

// when
val (isValid, report) = manifestsToReport(manifest, typesManifest)

// then
assertSoftly {
isValid shouldBe true
report shouldBe """
Overall result:
${'\u001b'}[32m✔ VALID${'\u001b'}[0m
Inputs:
None.
Outputs:
None.
""".trimIndent()
}
}

test("enum: missing allowed values") {
// when
val manifest = """
Expand Down

0 comments on commit b8c09e5

Please sign in to comment.