-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unit & Integration #15
base: master
Are you sure you want to change the base?
Conversation
val postRequest = post(baseUri / "appointments", requestBody) | ||
val maybeCreatedAppointment = response(postRequest).unsafeRunSync().as[Appointment] | ||
maybeCreatedAppointment shouldBe 'right | ||
val createdGameAppointment = maybeCreatedAppointment.right.get |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
horrible como se ve en github, pero bueno es la forma que sugiere la docu de ScalaTest para verificar el tipo de Either 🤷♂
retrievedGameAppointment shouldBe createdGameAppointment | ||
} | ||
|
||
object RequestUtils { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
esto en algun momento va a terminar siendo un DSL cross para todos los IT
.changeSport(TennisSingle) | ||
.addResult(Result(List(palan), List(zeta), 3, 2)) | ||
|
||
updated.winner shouldBe 'defined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sameeeeeeee
implicit val timer: Timer[IO] = IO.timer(ec) | ||
|
||
val baseUri = Uri.unsafeFromString("http://localhost:8080") | ||
val router: HttpRoutes[IO] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
La idea es cada IT extienda este trait y define el servicio
o routes
que quiera probar, y asi evitar levantar un Server con todas las rutas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bueni pero agregame pure config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Si bien te comente varias cosas que me parece que se pueden mejorar, prefiero tener tests a no tener. Asi que adelante y gracias y perdon por tardar tanto.
val retrievedGameAppointment = maybeCreatedAppointment.right.get | ||
|
||
retrievedGameAppointment shouldBe createdGameAppointment | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Se me hace que los tests deberiamos escribirlos de forma funcional tambien.
for {
...
createdAppointment <- response(postRequest)
...
retrievedAppointment <- response(getRequest)
} yield createdAppointment shouldBe retrievedAppointment
que todo eso devuelva IO[TestResult]
, despues agarras todos esos IO[TestResult]
, los metes en una lista y los corres en paralelo (.forEachPar
en ZIO) en tu "TestMain".
Tambien aca tiene mas sentido NO usar either u option ademas de IO. Que el getAppointment
te falle con un AppointmentNotFound
hace que no tengas que maybeRetrievedAppointment shouldBe 'right
y despues val retrievedGameAppointment = maybeCreatedAppointment.right.get
. IO "cortocircuitea" si no te lo encontro, y listo, tu test falla. Y si lo encontró ya lo tenes, no tenes que andar preguntando si es right o left o some o none.
import com.zeta.playthegame.util.Generators | ||
import org.scalatest.{FlatSpecLike, Matchers} | ||
|
||
class GameSpec extends FlatSpecLike with Matchers with Generators { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No veo que uses ningun Generator
aca. Tampoco veo que en ESTE pr hayas agregado el archivocom.zeta.playthegame.util.Generators
como para ver de que se trata.
implicit val timer: Timer[IO] = IO.timer(ec) | ||
|
||
val baseUri = Uri.unsafeFromString("http://localhost:8080") | ||
val router: HttpRoutes[IO] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bueni pero agregame pure config.
No description provided.