feat: replace browser login with imported Reddit sessions
This commit is contained in:
1 parent
2b0545afcf
commit
c483c7b8be
76 files changed
+2048
-2828
No files matched your search
+22
-3
@@ -16,7 +16,9 @@ describe('Database Client', () => {
|
||||
const config = getTestConfig({ database: { path: ':memory:' } });
|
||||
const db = createDatabase(config);
|
||||
const journalMode = db.pragma('journal_mode', { simple: true }) as string;
|
||||
expect(journalMode).toBe('wal');
|
||||
// SQLite uses an in-memory journal for the special :memory: database;
|
||||
// file-backed databases use WAL in production.
|
||||
expect(['wal', 'memory']).toContain(journalMode);
|
||||
db.close();
|
||||
});
|
||||
|
||||
@@ -103,8 +105,25 @@ describe('Database Client', () => {
|
||||
const tables = db
|
||||
.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%'")
|
||||
.all() as { name: string }[];
|
||||
// processed_posts, sent_messages, successful_messages, activity_log, reddit_users
|
||||
expect(tables.length).toBe(5);
|
||||
// processed_posts, sent_messages, successful_messages, activity_log, reddit_users, delivery_outbox, conversation_states, conversation_outcomes
|
||||
expect(tables.length).toBe(8);
|
||||
});
|
||||
|
||||
it('tracks schema version and migrates a legacy sent_messages table transactionally', () => {
|
||||
db.exec(`
|
||||
CREATE TABLE processed_posts (id TEXT PRIMARY KEY, subreddit TEXT NOT NULL, author TEXT NOT NULL, title TEXT NOT NULL, image_url TEXT, image_analysis TEXT, generated_message TEXT, processed_at INTEGER NOT NULL, message_sent INTEGER DEFAULT 0, error TEXT);
|
||||
CREATE TABLE sent_messages (id INTEGER PRIMARY KEY AUTOINCREMENT, post_id TEXT NOT NULL, recipient TEXT NOT NULL, subject TEXT NOT NULL, message TEXT NOT NULL, sent_at INTEGER NOT NULL);
|
||||
INSERT INTO processed_posts VALUES ('post-1', 'test', 'author', 'title', NULL, NULL, NULL, 1, 0, NULL);
|
||||
INSERT INTO sent_messages (post_id, recipient, subject, message, sent_at) VALUES ('post-1', 'recipient', 'subject', 'message', 2);
|
||||
`);
|
||||
|
||||
runMigrations(db);
|
||||
|
||||
expect(db.pragma('user_version', { simple: true })).toBeGreaterThan(0);
|
||||
expect(db.prepare('SELECT post_id FROM sent_messages').get()).toEqual({ post_id: 'post-1' });
|
||||
const postId = db.prepare('PRAGMA table_info(sent_messages)').all().find((column: { name: string }) => column.name === 'post_id') as { notnull: number };
|
||||
expect(postId.notnull).toBe(0);
|
||||
expect(db.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'delivery_outbox'").get()).toBeDefined();
|
||||
});
|
||||
|
||||
it('processed_posts has correct schema', () => {
|
||||
|
||||
Reference in new issue
Block a user