Skip to content
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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Unit & Integration #15

wants to merge 6 commits into from

Conversation

jzelayeta
Copy link
Owner

No description provided.

val postRequest = post(baseUri / "appointments", requestBody)
val maybeCreatedAppointment = response(postRequest).unsafeRunSync().as[Appointment]
maybeCreatedAppointment shouldBe 'right
val createdGameAppointment = maybeCreatedAppointment.right.get
Copy link
Owner Author

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 {
Copy link
Owner Author

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
Copy link
Owner Author

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]
Copy link
Owner Author

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

Copy link
Collaborator

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.

Copy link
Collaborator

@palanga palanga left a 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
}
Copy link
Collaborator

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 {
Copy link
Collaborator

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]
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants