Skip to content

Commit

Permalink
simplify a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
yurique committed Nov 16, 2023
1 parent 5d00d22 commit abc0cbe
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ import io.k8s.apimachinery.pkg.api.resource.Quantity

object TestPodSpec {

val alpine: PodSpec = PodSpec(
val alpine: PodSpec = alpine(None)

def alpine(command: Seq[String]): PodSpec = alpine(command.some)

private def alpine(command: Option[Seq[String]]): PodSpec = PodSpec(
containers = Seq(
Container(
name = "test",
image = "alpine".some,
command = command,
imagePullPolicy = "IfNotPresent".some,
resources = ResourceRequirements(
requests = Map(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ class JobsApiTest
template = PodTemplateSpec(
metadata = Option(ObjectMeta(name = Option(resourceName))),
spec = Option(
TestPodSpec.alpine.copy(
restartPolicy = "Never".some
)
TestPodSpec.alpine.copy(restartPolicy = "Never".some)
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,32 +63,18 @@ class PodsApiTest

def testPod(podName: String, labels: Map[String, String] = Map.empty): Pod = Pod(
metadata = Option(ObjectMeta(name = Option(podName), labels = Option(labels))),
spec = TestPodSpec.alpine
.copy(
containers = TestPodSpec.alpine.containers.map { container =>
container.copy(
command = Option(Seq("sh", "-c", "sleep 120"))
)
}
)
.some
spec = TestPodSpec.alpine(command = Seq("sh", "-c", "sleep 120")).some
)

def testPodWithLogs(podName: String, labels: Map[String, String] = Map.empty): Pod = Pod(
metadata = Option(ObjectMeta(name = Option(podName), labels = Option(labels))),
spec = TestPodSpec.alpine
.copy(
containers = TestPodSpec.alpine.containers.map { container =>
container.copy(
command = Option(
Seq(
"sh",
"-c",
"echo line 1; sleep 1; echo line 2; sleep 2; echo line 3; echo line 4; echo line 5; echo line 6"
)
)
)
}
spec = TestPodSpec
.alpine(command =
Seq(
"sh",
"-c",
"echo line 1; sleep 1; echo line 2; sleep 2; echo line 3; echo line 4; echo line 5; echo line 6"
)
)
.some
)
Expand Down

0 comments on commit abc0cbe

Please sign in to comment.