Skip to content

Commit

Permalink
update OutputTest
Browse files Browse the repository at this point in the history
Signed-off-by: Julia Plewa <jplewa@virtuslab.com>
  • Loading branch information
jplewa committed Sep 23, 2023
1 parent 2d4c7e4 commit 78e8fbd
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions sdk/src/test/kotlin/com/pulumi/kotlin/OutputTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import org.junit.jupiter.api.Test
import java.util.concurrent.CompletableFuture
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertNotEquals
import kotlin.test.assertTrue

class OutputTest {
Expand Down Expand Up @@ -43,8 +42,8 @@ class OutputTest {
fun `interpolates unknown outputs`() {
// given
val output1 = Output.of("value1")
val output2 = Output.of("value2")
val output3 = OutputInternal(CompletableFuture.completedFuture(OutputData.unknown<String>()))
val output2 = unknownOutput()
val output3 = Output.of("value3")

// when
val result = runBlocking {
Expand All @@ -68,8 +67,8 @@ class OutputTest {
fun `interpolates secret outputs`() {
// given
val output1 = Output.of("value1")
val output2 = Output.of("value2")
val output3 = Output.ofSecret("value3")
val output2 = Output.ofSecret("value2")
val output3 = Output.of("value3")

// when
val result = runBlocking {
Expand All @@ -92,9 +91,9 @@ class OutputTest {
@Test
fun `interpolates unknown and secret outputs`() {
// given
val output1 = OutputInternal(CompletableFuture.completedFuture(OutputData.unknown<String>()))
val output1 = unknownOutput()
val output2 = Output.ofSecret("value2")
val output3 = OutputInternal(CompletableFuture.completedFuture(OutputData.unknown<String>()))
val output3 = unknownOutput()

// when
val result = runBlocking {
Expand All @@ -118,9 +117,8 @@ class OutputTest {
fun `interpolates outputs that are both unknown and secret`() {
// given
val output1 = Output.of("value1")
val output2 = Output.ofSecret("value2")
val output3 =
(OutputInternal(CompletableFuture.completedFuture(OutputData.unknown<String>())) as Output<String>).asSecret()
val output2 = unknownOutput().asSecret()
val output3 = Output.of("value3")

// when
val result = runBlocking {
Expand All @@ -140,6 +138,10 @@ class OutputTest {
assertEquals(javaResult.isSecret(), result.isSecret())
}

private fun unknownOutput(): Output<String> {
return OutputInternal(CompletableFuture.completedFuture(OutputData.unknown()))
}

private fun Output<String>.getValue(): String? {
return (this as OutputInternal<String>)
.dataAsync
Expand Down

0 comments on commit 78e8fbd

Please sign in to comment.