Skip to content

Commit

Permalink
test(keel): remove duplicate tests from ImportDeliveryConfigTaskTests
Browse files Browse the repository at this point in the history
The deleted tests are the cases/scenarios which are already covered as part of the commit: b85fb76.

These tests covers up the http 4xx error cases of the API : keelService.publishDeliveryConfig.

Tests deleted are : 1. 'keel access denied error', 2. 'delivery config parsing error'.
  • Loading branch information
Pranav-b-7 committed Feb 27, 2024
1 parent 9f8028a commit 9ffbb26
Showing 1 changed file with 0 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import com.netflix.spinnaker.orca.igor.ScmService
import com.netflix.spinnaker.orca.keel.model.DeliveryConfig
import com.netflix.spinnaker.orca.keel.task.ImportDeliveryConfigTask
import com.netflix.spinnaker.orca.keel.task.ImportDeliveryConfigTask.Companion.UNAUTHORIZED_SCM_ACCESS_MESSAGE
import com.netflix.spinnaker.orca.keel.task.ImportDeliveryConfigTask.SpringHttpError
import com.netflix.spinnaker.orca.pipeline.model.DefaultTrigger
import com.netflix.spinnaker.orca.pipeline.model.GitTrigger
import com.netflix.spinnaker.orca.pipeline.model.PipelineExecutionImpl
Expand All @@ -41,21 +40,14 @@ import io.mockk.every
import io.mockk.mockk
import io.mockk.slot
import io.mockk.verify
import org.springframework.http.HttpStatus.BAD_REQUEST
import org.springframework.http.HttpStatus.FORBIDDEN
import retrofit.RetrofitError
import retrofit.client.Response
import retrofit.converter.JacksonConverter
import retrofit.mime.TypedInput
import strikt.api.expectThat
import strikt.api.expectThrows
import strikt.assertions.contains
import strikt.assertions.isA
import strikt.assertions.isEqualTo
import strikt.assertions.isNotEqualTo
import strikt.assertions.isNotNull
import java.time.Instant
import java.time.temporal.ChronoUnit

internal class ImportDeliveryConfigTaskTests : JUnit5Minutests {
data class ManifestLocation(
Expand Down Expand Up @@ -111,34 +103,6 @@ internal class ImportDeliveryConfigTaskTests : JUnit5Minutests {
context
)
)

val parsingError = SpringHttpError(
status = BAD_REQUEST.value(),
error = BAD_REQUEST.reasonPhrase,
message = "Parsing error",
details = mapOf(
"message" to "Parsing error",
"path" to listOf(
mapOf(
"type" to "SomeClass",
"field" to "someField"
)
),
"pathExpression" to ".someField"
),
// Jackson writes this as ms-since-epoch, so we need to strip off the nanoseconds, since we'll
// be round-tripping it through Jackson before testing for equality.
timestamp = Instant.now().truncatedTo(ChronoUnit.MILLIS)
)

val accessDeniedError = SpringHttpError(
status = FORBIDDEN.value(),
error = FORBIDDEN.reasonPhrase,
message = "Access denied",
// Jackson writes this as ms-since-epoch, so we need to strip off the nanoseconds, since we'll
// be round-tripping it through Jackson before testing for equality.
timestamp = Instant.now().truncatedTo(ChronoUnit.MILLIS)
)
}

private fun ManifestLocation.toMap() =
Expand Down Expand Up @@ -365,66 +329,6 @@ internal class ImportDeliveryConfigTaskTests : JUnit5Minutests {
}
}

context("keel access denied error") {
modifyFixture {
with(scmService) {
every {
getDeliveryConfigManifest(
manifestLocation.repoType,
manifestLocation.projectKey,
manifestLocation.repositorySlug,
manifestLocation.directory,
manifestLocation.manifest,
manifestLocation.ref
)
} throws RetrofitError.httpError(
"http://keel",
Response(
"http://keel", 403, "", emptyList(),
JacksonConverter(objectMapper).toBody(accessDeniedError) as TypedInput
),
null, null
)
}
}

test("task fails and includes the error details returned by keel") {
val result = execute(manifestLocation.toMap())
expectThat(result.status).isEqualTo(ExecutionStatus.TERMINAL)
expectThat(result.context["error"]).isA<SpringHttpError>().isEqualTo(accessDeniedError)
}
}

context("delivery config parsing error") {
modifyFixture {
with(scmService) {
every {
getDeliveryConfigManifest(
manifestLocation.repoType,
manifestLocation.projectKey,
manifestLocation.repositorySlug,
manifestLocation.directory,
manifestLocation.manifest,
manifestLocation.ref
)
} throws RetrofitError.httpError(
"http://keel",
Response(
"http://keel", 400, "", emptyList(),
JacksonConverter(objectMapper).toBody(parsingError) as TypedInput
),
null, null
)
}
}

test("task fails and includes the error details returned by keel") {
val result = execute(manifestLocation.toMap())
expectThat(result.status).isEqualTo(ExecutionStatus.TERMINAL)
expectThat(result.context["error"]).isA<SpringHttpError>().isEqualTo(parsingError)
}
}

context("retryable failure to call downstream services") {
modifyFixture {
with(scmService) {
Expand Down

0 comments on commit 9ffbb26

Please sign in to comment.