refactor(tmux): export sweepTmuxSessionsWith and add runtime tests
This commit is contained in:
@@ -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"])
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user