Initial scaffolding
This commit is contained in:
1 parent
15a0ff43de
commit
989415ec1f
20 files changed
+743
No files matched your search
+40
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env perl
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More;
|
||||
use File::Temp qw(tempfile);
|
||||
use FindBin qw($RealBin);
|
||||
use lib "$RealBin/../lib";
|
||||
|
||||
use_ok('Mnemosyne::Config');
|
||||
|
||||
my (undef, $tmp) = tempfile(SUFFIX => '.conf', UNLINK => 1);
|
||||
open my $fh, '>', $tmp or die $!;
|
||||
print $fh <<'END';
|
||||
[bot]
|
||||
token = abc123
|
||||
webhook_secret = secret456
|
||||
allowed_chat_ids = 111, 222, 333
|
||||
listen_port = 8765
|
||||
|
||||
[db]
|
||||
path = /var/lib/mnemosyne/mnemosyne.db
|
||||
|
||||
[app]
|
||||
timezone = America/Chicago # inline comment
|
||||
digest_time = 07:30
|
||||
END
|
||||
close $fh;
|
||||
|
||||
my $cfg = Mnemosyne::Config->new($tmp);
|
||||
isa_ok($cfg, 'Mnemosyne::Config');
|
||||
|
||||
is($cfg->get('bot', 'token'), 'abc123', 'bot.token');
|
||||
is($cfg->get('bot', 'listen_port'), '8765', 'bot.listen_port');
|
||||
is($cfg->get('app', 'digest_time'), '07:30', 'app.digest_time');
|
||||
is($cfg->get('app', 'timezone'), 'America/Chicago', 'inline comment stripped');
|
||||
is($cfg->get('db', 'path'), '/var/lib/mnemosyne/mnemosyne.db', 'db.path');
|
||||
is_deeply($cfg->allowed_chat_ids, [111, 222, 333], 'allowed_chat_ids parsed');
|
||||
is($cfg->get('bot', 'nonexistent'), undef, 'missing key returns undef');
|
||||
|
||||
done_testing;
|
||||
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env perl
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More;
|
||||
use File::Temp qw(tempfile);
|
||||
use FindBin qw($RealBin);
|
||||
use lib "$RealBin/../lib";
|
||||
|
||||
use_ok('Mnemosyne::DB');
|
||||
|
||||
my (undef, $tmp) = tempfile(SUFFIX => '.db', UNLINK => 1);
|
||||
|
||||
my $db = Mnemosyne::DB->new($tmp);
|
||||
isa_ok($db, 'Mnemosyne::DB');
|
||||
ok($db->dbh, 'dbh returns a handle');
|
||||
|
||||
# Schema applied
|
||||
my @tables = map { $_->[0] }
|
||||
@{ $db->dbh->selectall_arrayref("SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' ORDER BY name") };
|
||||
is_deeply(\@tables, [qw(completions config tasks)], 'expected tables created');
|
||||
|
||||
# Config defaults
|
||||
is($db->config_get('digest_time'), '06:30', 'default digest_time');
|
||||
is($db->config_get('upcoming_horizon'), '7', 'default upcoming_horizon');
|
||||
|
||||
# config_set round-trip
|
||||
$db->config_set('digest_time', '07:00');
|
||||
is($db->config_get('digest_time'), '07:00', 'config_set persists');
|
||||
|
||||
done_testing;
|
||||
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env perl
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More;
|
||||
|
||||
# Schedule.pm unit tests — date math across all five task classes.
|
||||
# This file is a placeholder; tests will be added as Schedule.pm is implemented.
|
||||
#
|
||||
# Priority test cases to cover:
|
||||
#
|
||||
# monthly_date:
|
||||
# - Normal case: day_of_month=15, today=2026-06-15 → due
|
||||
# - Short-month clamp: day_of_month=31, today=2026-06-30 → due (last day of June)
|
||||
# - Short-month clamp: day_of_month=31, today=2026-06-15 → upcoming
|
||||
# - Overdue: day_of_month=1, today=2026-06-05, no completion → overdue
|
||||
#
|
||||
# monthly_weekday:
|
||||
# - 4th Monday: 2026-06 → 2026-06-22
|
||||
# - last Monday: 2026-06 → 2026-06-29
|
||||
# - ordinal=1, weekday=0 (Mon): 2026-06 → 2026-06-01
|
||||
#
|
||||
# every_n_period:
|
||||
# - every 2 weeks from 2026-01-01: check correct occurrence dates
|
||||
# - every 3 months from 2026-01-15: Feb has 28 days — verify month arithmetic
|
||||
#
|
||||
# interval:
|
||||
# - never completed: due = created_at + interval_days
|
||||
# - completed yesterday: interval=30 → not due yet
|
||||
# - completed 31 days ago: interval=30 → overdue
|
||||
#
|
||||
# floating:
|
||||
# - high priority → always shown
|
||||
# - medium: shown at day 0 and day 3, not at day 1 or 2
|
||||
|
||||
plan skip_all => 'Schedule.pm not yet implemented';
|
||||
done_testing;
|
||||
Reference in new issue
Block a user