Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mgoworko committed Sep 10, 2024
1 parent 9113a0f commit 909c3e7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ trait ProcessJsonMigration extends SlickMigration with NuTables with LazyLogging

override protected def migrateActions
: DBIOAction[Seq[Int], NoStream, Effect.Read with Effect.Read with Effect.Write] = {
logger.error("Migration")
for {
allVersionIds <- processVersionsTableWithUnit.map(pve => (pve.id, pve.processId)).result
updated <- DBIOAction.sequence(allVersionIds.zipWithIndex.map { case ((id, processId), scenarioIndex) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,17 +278,9 @@ class DbScenarioActivityRepository(override protected val dbRef: DbRef)(
}

def getActivityStats: DB[Map[String, Int]] = {
val activityTypesWithLegacyComments = Set(
ScenarioActivityType.ScenarioDeployed,
ScenarioActivityType.ScenarioPaused,
ScenarioActivityType.ScenarioCanceled,
ScenarioActivityType.ScenarioModified,
ScenarioActivityType.ScenarioNameChanged,
ScenarioActivityType.CommentAdded,
)
val findScenarioProcessActivityStats = for {
attachmentsTotal <- attachmentsTable.length.result
commentsTotal <- scenarioActivityTable.filter(_.activityType inSet activityTypesWithLegacyComments).length.result
commentsTotal <- scenarioActivityTable.filter(_.comment.isDefined).length.result
} yield Map(
AttachmentsTotal -> attachmentsTotal,
CommentsTotal -> commentsTotal,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,15 @@ class V1_056__MigrateActionsAndCommentsToScenarioActivities
_ <- commentsDefinitions.table += commentEntity(process)
_ <- processActionsDefinitions.table += processActionEntity(process)
result <- migration.migrateActions
} yield result._1
} yield (process, result._1)

val activitiesCreatedDuringMigration = Await.result(runner.run(dbOperations), Duration.Inf)

activitiesCreatedDuringMigration shouldBe
val (createdProcess, insertedActivities) = Await.result(runner.run(dbOperations), Duration.Inf)
insertedActivities shouldBe
List(
ScenarioActivityEntityData(
id = -1,
activityType = "SCENARIO_DEPLOYED",
scenarioId = 1,
scenarioId = createdProcess.id.value,
activityId = actionId,
userId = None,
userName = user,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ trait DbTesting extends BeforeAndAfterEach with BeforeAndAfterAll {

def cleanDB(): Try[Unit] = Using(testDbRef.db.createSession()) { session =>
session.prepareStatement("""delete from "process_attachments"""").execute()
session.prepareStatement("""delete from "process_comments"""").execute()
session.prepareStatement("""delete from "process_actions"""").execute()
session.prepareStatement("""delete from "scenario_activities"""").execute()
session.prepareStatement("""delete from "process_versions"""").execute()
session.prepareStatement("""delete from "tags"""").execute()
session.prepareStatement("""delete from "environments"""").execute()
Expand Down

0 comments on commit 909c3e7

Please sign in to comment.