forked from kimonberlin/salebot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testme.pl
executable file
·42 lines (34 loc) · 1.28 KB
/
testme.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/perl
use strict;
use warnings;
use utf8; # The source code itself has utf8 chars
use lib "./lib";
use Test::More;
use Loc;
use ConfigFile;
use Stat;
use RCParser;
use Logging;
loc_init("config/lexicon.txt", "fr");
ok (1 + 1 == 2, "dummy test");
is (loc("lang"), "français", "lang translation exists");
is (loc("no_such_key"), "<no_such_key>", "non-existent key");
is ($USER_NAMESPACE, "Utilisateur", "global variables from loc");
config_init();
is ($config->{wiki_user}, "Salebot", "config initialized");
stat_init();
ok (defined $stat->{recent_revert_count}, "stat defined");
ok ($stat->{last_reset_time} > 0, "stat initialized");
is($config->{log_file}, "salebot2.log", "log file name");
$config->{log_file}="testme.log";
$config->{log_conf_file}="config/log-testme.conf";
log_init($config->{log_conf_file}, $config->{log_dir}, $config->{log_file});
my $text='14[[07Spécial:Log/newusers14]]4 create210 02 5* 03Gribeco 5* 10created new account Utilisateur:abc éè : test salebot';
utf8::encode($text);
my $rc =parse_rc_message ($text);
is ($rc->{action}, "create2", "create2 action");
is ($rc->{user}, "Gribeco", "create2 user");
my $expected_user = "abc éè";
utf8::encode($expected_user);
is ($rc->{new_user}, $expected_user, "create2 newuser");
done_testing();