2017-12-15 1 views
-1

ich scalatest folgend bin mit:Wie verwende ich den algebraischen Datentyp für scalatest?

class AuthLdapSpec extends FlatSpec with Matchers { 

    "The user" should "be signin successfully." in { 

    AuthLdap.signin("[email protected]")("password").value.unsafeRunSync() match { 
     case Right(r) => println(r) 
     case Left(l) => println(l) 
    } 
    } 

} 

Wie Sie sehen können, ist die Funktion AuthLdap.signin("[email protected]")("password").value.unsafeRunSync() kehrt Either[A, B].
Wie kann ich überprüfen, ob der Rückgabetyp Right oder Left ist?
ich wie folgt versucht haben:

AuthLdap.signin("[email protected]")("password").value.unsafeRunSync() should be (Right) 

Aber der Compiler beschwert:

Error:(15, 93) [Artima SuperSafe] Values of type Either[String,io.khinkali.auth.AuthLdapUser] and scala.util.Right.type may not be compared for equality with ScalaTest's be matcher syntax. If you really want this expression to compile, configure Artima SuperSafe to allow Either[String,io.khinkali.auth.AuthLdapUser] and scala.util.Right.type to be compared for equality. For more information on this kind of error, see: http://www.artima.com/supersafe_user_guide.html#safer-equality

Antwort

1

Alternativ, wenn Sie nur wollen, behaupten, dass es ein ‚Recht‘ mit einem beliebigen Wert

AuthLdap.signin("[email protected]")("password").value.unsafeRunSync().isRight should be true 
Verwandte Themen