fix(tmux): sweep suffixed stale isolated sessions
This commit is contained in:
committed by
YeonGyu-Kim
parent
0c8e546c57
commit
8c5ca73634
@@ -99,6 +99,19 @@ describe("sweepStaleOmoAgentSessionsWith", () => {
|
||||
expect(fixture.killed).toEqual(["omo-agents-99991", "omo-agents-99992"])
|
||||
})
|
||||
|
||||
it("#given suffixed sessions with dead PIDs #when sweep called #then they are also killed", async () => {
|
||||
// given
|
||||
fixture.setCandidates(["omo-agents-99991-1", "omo-agents-99992-abc123"])
|
||||
fixture.setAlive(() => false)
|
||||
|
||||
// when
|
||||
const result = await sweepStaleOmoAgentSessionsWith(fixture.deps)
|
||||
|
||||
// then
|
||||
expect(result).toBe(2)
|
||||
expect(fixture.killed).toEqual(["omo-agents-99991-1", "omo-agents-99992-abc123"])
|
||||
})
|
||||
|
||||
it("#given session matches current PID #when sweep called #then it is NOT killed", async () => {
|
||||
// given
|
||||
fixture.setCandidates([`omo-agents-${fixture.deps.currentPid}`, "omo-agents-99999"])
|
||||
@@ -139,9 +152,9 @@ describe("sweepStaleOmoAgentSessionsWith", () => {
|
||||
expect(fixture.killSessionMock).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it("#given non-matching sessions mixed in #when sweep called #then only omo-agents-<pid> sessions are considered", async () => {
|
||||
it("#given non-matching sessions mixed in #when sweep called #then only supported omo-agents session names are considered", async () => {
|
||||
// given
|
||||
fixture.setCandidates(["main", "omo-agents-99999", "other-session", "omo-agents-abc"])
|
||||
fixture.setCandidates(["main", "omo-agents-99999", "omo-agents-99999-1-2", "other-session", "omo-agents-abc"])
|
||||
fixture.setAlive(() => false)
|
||||
|
||||
// when
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const STALE_SESSION_PATTERN = /^omo-agents-(\d+)$/
|
||||
const STALE_SESSION_PATTERN = /^omo-agents-(\d+)(?:-([A-Za-z0-9]+))?$/
|
||||
|
||||
function getErrorMessage(error: unknown): string {
|
||||
if (error instanceof Error) {
|
||||
|
||||
Reference in New Issue
Block a user