refactor(tmux): export sweepTmuxSessionsWith and add runtime tests

This commit is contained in:
YeonGyu-Kim
2026-04-28 10:44:56 +09:00
parent 96161cc0e6
commit c9e544a667
4 changed files with 189 additions and 36 deletions
@@ -1,5 +1,5 @@
import { beforeEach, describe, expect, it, mock } from "bun:test"
import { sweepStaleOmoAgentSessionsWith, type SweepDeps } from "./stale-session-sweep"
import { sweepStaleOmoAgentSessionsWith, sweepTmuxSessionsWith, type SweepDeps } from "./stale-session-sweep"
type SweepFixture = {
deps: SweepDeps
@@ -152,3 +152,25 @@ describe("sweepStaleOmoAgentSessionsWith", () => {
expect(fixture.killed).toEqual(["omo-agents-99999"])
})
})
describe("sweepTmuxSessionsWith", () => {
let fixture: SweepFixture
beforeEach(() => {
fixture = createFixture()
})
it("#given custom predicate for team sessions #when shared sweep called #then only matching sessions are killed", async () => {
// given
fixture.setCandidates(["omo-team-A", "omo-team-B", "main", "omo-agents-99999"])
// when
const result = await sweepTmuxSessionsWith(fixture.deps, {
predicate: (sessionName) => sessionName.startsWith("omo-team-"),
})
// then
expect(result).toEqual(["omo-team-A", "omo-team-B"])
expect(fixture.killed).toEqual(["omo-team-A", "omo-team-B"])
})
})