Skip to content

Commit 4c9ab1c

Browse files
authored
Don't assume non-null values for any fields in testMatrix (#61)
* Don't assume non-null values for any fields in testMatrix * adding test to cover this scenario
1 parent 01e6936 commit 4c9ab1c

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/testRunner/TestExecutionStore.kt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,16 @@ internal class TestExecutionStore(
4646
suspend fun getTestExecutionSteps(
4747
testMatrix: TestMatrix
4848
): List<Step> {
49-
return getTestExecutionSteps(
50-
projectId = testMatrix.projectId!!,
51-
historyId = testMatrix.resultStorage.toolResultsExecution?.historyId!!,
52-
executionId = testMatrix.resultStorage.toolResultsExecution.executionId!!
53-
)
49+
return testMatrix.projectId?.let { projectId ->
50+
testMatrix.resultStorage.toolResultsExecution?.historyId?.let { historyId ->
51+
testMatrix.resultStorage.toolResultsExecution.executionId?.let { executionId ->
52+
getTestExecutionSteps(
53+
projectId = projectId,
54+
historyId = historyId,
55+
executionId = executionId
56+
)
57+
}
58+
}
59+
} ?: emptyList()
5460
}
5561
}

AndroidXCI/lib/src/test/kotlin/dev/androidx/ci/testRunner/TestExecutionStoreTest.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,24 @@ internal class TestExecutionStoreTest {
8181
assertThat(outputSteps).hasSize(2)
8282
assertThat(outputSteps).containsExactlyElementsIn(inputSteps)
8383
}
84+
85+
@Test
86+
fun getExecutionStepsNullValuesForExecutionIdHistoryId() = runBlocking<Unit> {
87+
val resultPath = "${fakeBackend.fakeGoogleCloudApi.rootGcsPath}/my-test-matrix-results"
88+
val testMatrix = fakeBackend.fakeFirebaseTestLabApi.createTestMatrix(
89+
projectId = fakeBackend.firebaseProjectId,
90+
requestId = "requestId",
91+
testMatrix = TestMatrix(
92+
resultStorage = ResultStorage(
93+
googleCloudStorage = GoogleCloudStorage(resultPath)
94+
),
95+
projectId = fakeBackend.firebaseProjectId,
96+
environmentMatrix = EnvironmentMatrix(),
97+
testSpecification = TestSpecification()
98+
)
99+
)
100+
101+
val outputSteps = testExecutionStore.getTestExecutionSteps(testMatrix)
102+
assertThat(outputSteps).isEmpty()
103+
}
84104
}

0 commit comments

Comments
 (0)