feat(events,sessions): ProjectProfileBoundEvent reduced into session state
This commit is contained in:
@@ -10,6 +10,8 @@ import com.correx.core.events.events.WorkflowStartedEvent
|
||||
import com.correx.core.events.types.SessionId
|
||||
import com.correx.core.events.types.StageId
|
||||
import com.correx.core.events.types.TransitionId
|
||||
import com.correx.core.events.events.ProjectProfileBoundEvent
|
||||
import com.correx.core.sessions.BoundProjectProfile
|
||||
import com.correx.core.sessions.BoundWorkspace
|
||||
import com.correx.core.sessions.DefaultSessionReducer
|
||||
import com.correx.core.sessions.SessionState
|
||||
@@ -278,6 +280,53 @@ class DefaultSessionReducerTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `ProjectProfileBoundEvent reduces into boundProjectProfile`() {
|
||||
val result = reducer.reduce(
|
||||
state = initialState(),
|
||||
event = stored(
|
||||
sessionId = sessionId,
|
||||
payload = ProjectProfileBoundEvent(
|
||||
sessionId = sessionId,
|
||||
workspaceRoot = "/repo",
|
||||
about = "kernel project",
|
||||
conventions = listOf("no bare try-catch"),
|
||||
commands = mapOf("test" to "./gradlew check"),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
BoundProjectProfile(
|
||||
about = "kernel project",
|
||||
conventions = listOf("no bare try-catch"),
|
||||
commands = mapOf("test" to "./gradlew check"),
|
||||
),
|
||||
result.boundProjectProfile,
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `boundProjectProfile is preserved by subsequent unrelated events`() {
|
||||
val withProfile = initialState().copy(
|
||||
boundProjectProfile = BoundProjectProfile(
|
||||
about = "kernel project",
|
||||
conventions = listOf("no bare try-catch"),
|
||||
commands = emptyMap(),
|
||||
),
|
||||
)
|
||||
|
||||
val result = reducer.reduce(
|
||||
state = withProfile,
|
||||
event = stored(
|
||||
sessionId = sessionId,
|
||||
payload = WorkflowStartedEvent(sessionId, workflowId = "wf", startStageId = StageId("s1")),
|
||||
),
|
||||
)
|
||||
|
||||
assertEquals("kernel project", result.boundProjectProfile?.about)
|
||||
}
|
||||
|
||||
private fun initialState() =
|
||||
SessionState(
|
||||
status = SessionStatus.CREATED
|
||||
|
||||
Reference in New Issue
Block a user