Skip to content

Commit

Permalink
Update JdbcDurableStateSpec.scala
Browse files Browse the repository at this point in the history
  • Loading branch information
pjfanning committed Apr 13, 2024
1 parent aca6203 commit 730c1f5
Showing 1 changed file with 13 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import pekko.actor._
import pekko.persistence.jdbc.state.{ MyPayload, OffsetSyntax }
import OffsetSyntax._
import pekko.persistence.jdbc.testkit.internal.{ H2, Postgres, SchemaType }
import pekko.persistence.typed.state.internal.DurableStateStoreException
import pekko.persistence.query.{ NoOffset, Offset, Sequence, UpdatedDurableState }
import pekko.stream.scaladsl.Sink
import org.scalatest.time.{ Millis, Seconds, Span }
Expand Down Expand Up @@ -113,23 +114,18 @@ abstract class JdbcDurableStateSpec(config: Config, schemaType: SchemaType) exte
}
}
}
"delete old object revision but not latest" in {
whenReady {
for {

n <- stateStoreString.upsertObject("p987", 1, "a valid string", "t123")
_ = n shouldBe pekko.Done
g <- stateStoreString.getObject("p987")
_ = g.value shouldBe Some("a valid string")
u <- stateStoreString.upsertObject("p987", 2, "updated valid string", "t123")
_ = u shouldBe pekko.Done
d <- stateStoreString.deleteObject("p987", 1)
_ = d shouldBe pekko.Done
h <- stateStoreString.getObject("p987")

} yield h
} { v =>
v.value shouldBe Some("updated valid string")
"fail to delete old object revision" in {
val f = for {
n <- stateStoreString.upsertObject("p987", 1, "a valid string", "t123")
_ = n shouldBe pekko.Done
g <- stateStoreString.getObject("p987")
_ = g.value shouldBe Some("a valid string")
u <- stateStoreString.upsertObject("p987", 2, "updated valid string", "t123")
_ = u shouldBe pekko.Done
d <- stateStoreString.deleteObject("p987", 1)
} yield d
whenReady(f.failed) { e =>
e shouldBe a[DurableStateStoreException]
}
}
"delete latest object revision but not older one" in {
Expand Down

0 comments on commit 730c1f5

Please sign in to comment.