@@ -3,6 +3,8 @@ package es.weso.shex.actions
3
3
import es .weso .rdf .jena .RDFAsJenaModel
4
4
import es .weso .rdf .nodes .IRI
5
5
import org .scalatest ._
6
+ import cats .effect .IO
7
+ import cats .data .EitherT
6
8
7
9
class TestSemanticActionTest extends FunSpec with Matchers with EitherValues {
8
10
@@ -13,10 +15,10 @@ class TestSemanticActionTest extends FunSpec with Matchers with EitherValues {
13
15
|:x :p 1 .
14
16
""" .stripMargin
15
17
val r = for {
16
- rdf <- RDFAsJenaModel .fromString(rdfStr," TURTLE" ,None )
17
- result <- TestSemanticAction .runAction(" print(s)" , IRI (" http://example.org/x" ),rdf)
18
+ rdf <- EitherT .liftF( RDFAsJenaModel .fromString(rdfStr," TURTLE" ,None ) )
19
+ result <- EitherT .fromEither[ IO ]( TestSemanticAction .runAction(" print(s)" , IRI (" http://example.org/x" ),rdf) )
18
20
} yield result
19
- r.fold(
21
+ r.value.unsafeRunSync. fold(
20
22
e => fail(s " Error: $e" ),
21
23
result => info(s " Result: $result" )
22
24
)
@@ -27,19 +29,20 @@ class TestSemanticActionTest extends FunSpec with Matchers with EitherValues {
27
29
|:x :p 1 .
28
30
""" .stripMargin
29
31
val r = for {
30
- rdf <- RDFAsJenaModel .fromString(rdfStr," TURTLE" ,None )
31
- result <- TestSemanticAction .runAction(" print(o) " , IRI (" http://example.org/x" ),rdf)
32
+ rdf <- EitherT .liftF( RDFAsJenaModel .fromString(rdfStr," TURTLE" ,None ) )
33
+ result <- EitherT .fromEither[ IO ]( TestSemanticAction .runAction(" print(o) " , IRI (" http://example.org/x" ),rdf) )
32
34
} yield result
33
- r.fold(
35
+ r.value.unsafeRunSync. fold(
34
36
e => fail(s " Error: $e" ),
35
37
result => info(s " Result: $result" )
36
38
)
37
39
}
38
40
it(s " Should run fail code " ) {
39
41
val r = for {
40
- result <- TestSemanticAction .runAction(" fail(s)" , IRI (" " ), RDFAsJenaModel .empty)
42
+ rdf <- EitherT .liftF(RDFAsJenaModel .empty)
43
+ result <- EitherT .fromEither[IO ](TestSemanticAction .runAction(" fail(s)" , IRI (" " ), rdf))
41
44
} yield result
42
- r.fold(
45
+ r.value.unsafeRunSync. fold(
43
46
e => info(s " Failed as expected: $e" ),
44
47
result => fail(s " Should fail but succeeded " )
45
48
)
0 commit comments