11import { describe , test , expect } from "bun:test"
2- import path from "path"
32import { Session } from "../../src/session"
43import { Todo } from "../../src/session/todo"
54import { Bus } from "../../src/bus"
65import { Log } from "../../src/util/log"
76import { Instance } from "../../src/project/instance"
7+ import { tmpdir } from "../fixture/fixture"
88
9- const projectRoot = path . join ( __dirname , "../.." )
109Log . init ( { print : false } )
1110
1211describe ( "Todo: CRUD lifecycle" , ( ) => {
1312 test ( "update then get returns todos in order" , async ( ) => {
13+ await using tmp = await tmpdir ( { git : true } )
1414 await Instance . provide ( {
15- directory : projectRoot ,
15+ directory : tmp . path ,
1616 fn : async ( ) => {
1717 const session = await Session . create ( { } )
1818 const todos = [
@@ -37,8 +37,9 @@ describe("Todo: CRUD lifecycle", () => {
3737 } )
3838
3939 test ( "update with empty array clears all todos" , async ( ) => {
40+ await using tmp = await tmpdir ( { git : true } )
4041 await Instance . provide ( {
41- directory : projectRoot ,
42+ directory : tmp . path ,
4243 fn : async ( ) => {
4344 const session = await Session . create ( { } )
4445
@@ -57,8 +58,9 @@ describe("Todo: CRUD lifecycle", () => {
5758 } )
5859
5960 test ( "update replaces previous todos entirely" , async ( ) => {
61+ await using tmp = await tmpdir ( { git : true } )
6062 await Instance . provide ( {
61- directory : projectRoot ,
63+ directory : tmp . path ,
6264 fn : async ( ) => {
6365 const session = await Session . create ( { } )
6466
@@ -87,8 +89,9 @@ describe("Todo: CRUD lifecycle", () => {
8789 } )
8890
8991 test ( "get returns empty array for session with no todos" , async ( ) => {
92+ await using tmp = await tmpdir ( { git : true } )
9093 await Instance . provide ( {
91- directory : projectRoot ,
94+ directory : tmp . path ,
9295 fn : async ( ) => {
9396 const session = await Session . create ( { } )
9497
@@ -101,8 +104,9 @@ describe("Todo: CRUD lifecycle", () => {
101104 } )
102105
103106 test ( "publishes Todo.Event.Updated on update" , async ( ) => {
107+ await using tmp = await tmpdir ( { git : true } )
104108 await Instance . provide ( {
105- directory : projectRoot ,
109+ directory : tmp . path ,
106110 fn : async ( ) => {
107111 const session = await Session . create ( { } )
108112 let eventReceived = false
@@ -131,8 +135,9 @@ describe("Todo: CRUD lifecycle", () => {
131135 } )
132136
133137 test ( "todos are isolated between sessions" , async ( ) => {
138+ await using tmp = await tmpdir ( { git : true } )
134139 await Instance . provide ( {
135- directory : projectRoot ,
140+ directory : tmp . path ,
136141 fn : async ( ) => {
137142 const session1 = await Session . create ( { } )
138143 const session2 = await Session . create ( { } )
0 commit comments