Skip to content

Instantly share code, notes, and snippets.

View asvanberg's full-sized avatar

Andreas Svanberg asvanberg

  • Stockholm, Sweden
View GitHub Profile
@runarorama
runarorama / gist:a8fab38e473fafa0921d
Last active April 13, 2021 22:28
Compositional application architecture with reasonably priced monads
sealed trait Interact[A]
case class Ask(prompt: String)
extends Interact[String]
case class Tell(msg: String)
extends Interact[Unit]
trait Monad[M[_]] {
def pure[A](a: A): M[A]
import scalaz._, Scalaz._
object ErrorHandlingExample {
type PartNumber = String
sealed trait CpuType
case object Intel extends CpuType
case object Qualcomm extends CpuType
case class PhoneSpec(
@asvanberg
asvanberg / SomeTest.java
Created September 7, 2024 21:44
Solving the problem of emptying the database between each test when using Spring Boot and Testcontainers
/*
This showcases how to use a Testcontainers provided database to test a Spring
Boot application while isolating every test so that changes to the database
does not interfere with other tests.
It accomplishes this without any reliance on implementation details to empty
out specific tables or anything else. There is no global "rollback only"
transaction semantics. You can run assertions against the actual data in the
database if desired, including any schema changes.