-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#296] feat(library): add job.result, step.outcome, and step.conclusi…
…on (#1109) Co-authored-by: Piotr Krzemiński <3110813+krzema12@users.noreply.github.com>
- Loading branch information
Showing
7 changed files
with
113 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
library/src/main/kotlin/io/github/typesafegithub/workflows/domain/AbstractResult.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.github.typesafegithub.workflows.domain | ||
|
||
public abstract class AbstractResult internal constructor( | ||
private val value: String, | ||
) { | ||
public infix fun eq(status: Status): String = "$value == $status" | ||
|
||
public infix fun neq(status: Status): String = "$value != $status" | ||
|
||
override fun toString(): String = value | ||
|
||
public enum class Status { | ||
Success, | ||
Failure, | ||
Cancelled, | ||
Skipped, | ||
; | ||
|
||
override fun toString(): String = "'${name.lowercase()}'" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
library/src/test/kotlin/io/github/typesafegithub/workflows/domain/StepTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package io.github.typesafegithub.workflows.domain | ||
|
||
import io.github.typesafegithub.workflows.actions.actions.CheckoutV4 | ||
import io.github.typesafegithub.workflows.domain.AbstractResult.Status | ||
import io.github.typesafegithub.workflows.domain.actions.Action | ||
import io.kotest.core.spec.style.FunSpec | ||
import io.kotest.matchers.shouldBe | ||
|
||
class StepTest : FunSpec({ | ||
test("step.outcome") { | ||
val step0: Step = CommandStep(id = "step-0", command = "ls") | ||
step0.outcome.toString() shouldBe "steps.step-0.outcome" | ||
step0.outcome eq Status.Failure shouldBe "steps.step-0.outcome == 'failure'" | ||
step0.outcome eq Status.Cancelled shouldBe "steps.step-0.outcome == 'cancelled'" | ||
step0.outcome eq Status.Skipped shouldBe "steps.step-0.outcome == 'skipped'" | ||
step0.outcome eq Status.Success shouldBe "steps.step-0.outcome == 'success'" | ||
} | ||
test("step.conclusion") { | ||
val someStep: Step = ActionStep(id = "whatever", action = CheckoutV4(), outputs = Action.Outputs("whatever")) | ||
someStep.conclusion.toString() shouldBe "steps.whatever.conclusion" | ||
someStep.conclusion eq Status.Failure shouldBe "steps.whatever.conclusion == 'failure'" | ||
someStep.conclusion eq Status.Cancelled shouldBe "steps.whatever.conclusion == 'cancelled'" | ||
someStep.conclusion eq Status.Skipped shouldBe "steps.whatever.conclusion == 'skipped'" | ||
someStep.conclusion eq Status.Success shouldBe "steps.whatever.conclusion == 'success'" | ||
} | ||
}) |