Created
January 4, 2019 20:25
-
-
Save mattroberts297/b8049e2901aa67db7fb6c297213386d8 to your computer and use it in GitHub Desktop.
SignupSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def accCompiler[A: IsParseable[Id, ?]] | |
(f: Fixtures): SignupA ~> ArgsLog = | |
new (SignupA ~> ArgsLog) { | |
val l = Success.asRight[LogError] | |
def apply[C](fa: SignupA[C]): AL[C] = fa match { | |
case p: Parse[Id, A] => | |
(p, f.request) |> ArgsLog.lift | |
case g: GenSalt => | |
(g, f.salt) |> ArgsLog.lift | |
case g: GenHash => | |
(g, f.hash) |> ArgsLog.lift | |
case p: Persist => | |
(p, f.result) |> ArgsLog.lift | |
case w: WriteLog => | |
(w, l) |> ArgsLog.lift | |
} | |
} | |
it should "pass correct args" in { | |
val f = Fixtures() // Defaults as before. | |
val (ss, _) = signup(r).foldMap(accCompiler(f)).run | |
ss shouldBe(Vector( | |
Parse(r), | |
WriteLog(SignupModel.info("Parsed body")), | |
GenSalt(512), | |
WriteLog(SignupModel.info("Created salt")), | |
GenHash(p, s, 10000), | |
WriteLog(SignupModel.info("Created hash")), | |
Persist(User(e, h, s)), | |
WriteLog(SignupModel.info("Persisted user")) | |
)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment