Skip to content

Commit

Permalink
tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
lalalune committed Mar 25, 2024
1 parent 655b88d commit 8e3e855
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/lib/actions/__tests__/ignore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ describe("Ignore action tests", () => {
}

room_id = data?.room_id;
console.log("*** data", data);
console.log("Room ID", room_id);

await cleanup();
});
Expand Down Expand Up @@ -187,7 +189,7 @@ describe("Ignore action tests", () => {

return result.action === "IGNORE";
});
}, 60000);
}, 120000);

test("Action handler test 1: response should be ignore", async () => {
await runAiTest(
Expand All @@ -212,7 +214,7 @@ describe("Ignore action tests", () => {
return (lastMessage.content as Content).action === "IGNORE";
},
);
}, 60000);
}, 120000);

test("Action handler test 2: response should be ignore", async () => {
await runAiTest(
Expand All @@ -237,7 +239,7 @@ describe("Ignore action tests", () => {
return (lastMessage.content as Content).action === "IGNORE";
},
);
}, 60000);
}, 120000);

test("Expect ignore", async () => {
await runAiTest("Expect ignore", async () => {
Expand All @@ -257,5 +259,5 @@ describe("Ignore action tests", () => {

return (lastMessage.content as Content).action === "IGNORE";
});
}, 60000);
}, 120000);
});
1 change: 1 addition & 0 deletions src/lib/adapters/sqlite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ AND room_id = ?`;
}

async createRoom(room_id?: UUID): Promise<UUID> {
room_id = room_id || (v4() as UUID);
try {
const sql = "INSERT INTO rooms (id) VALUES (?)";
this.db.prepare(sql).run(room_id ?? (v4() as UUID));
Expand Down
5 changes: 4 additions & 1 deletion src/test/getOrCreateRelationship.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ export async function getOrCreateRelationship({

let room_id: UUID;
if (!rooms || rooms.length === 0) {
console.log("No room found for participants");
// If no room exists, create a new room for the relationship
room_id = await runtime.databaseAdapter.createRoom();
console.log("Created room", room_id);

// Add participants to the newly created room
await runtime.databaseAdapter.addParticipant(userA, room_id);
await runtime.databaseAdapter.addParticipant(userB, room_id);
} else {
console.log("Room found for participants", rooms[0]);
// If a room already exists, use the existing room
room_id = rooms[0];
}
Expand All @@ -49,5 +52,5 @@ export async function getOrCreateRelationship({
throw new Error("Failed to fetch the created relationship");
}
}
return { ...relationship, room_id: room_id };
return { ...relationship, room_id };
}

0 comments on commit 8e3e855

Please sign in to comment.