Remove code comments
This commit is contained in:
parent
a5e58493d8
commit
52d7c13013
17 changed files with 18 additions and 335 deletions
|
|
@ -1,6 +1,3 @@
|
|||
//! Integration tests for config layering and `[network]` sections, exercising
|
||||
//! the public `rustbot::config::parse_str` (no filesystem or environment).
|
||||
|
||||
use rustbot::config::parse_str;
|
||||
|
||||
#[test]
|
||||
|
|
@ -10,7 +7,6 @@ fn flat_config_is_a_single_network() {
|
|||
assert_eq!(cfgs[0].server, "irc.example.org");
|
||||
assert_eq!(cfgs[0].nick, "flatbot");
|
||||
assert_eq!(cfgs[0].channels, vec!["#a", "#b"]);
|
||||
// The label defaults to the server host.
|
||||
assert_eq!(cfgs[0].name, "irc.example.org");
|
||||
}
|
||||
|
||||
|
|
@ -26,17 +22,17 @@ fn sections_inherit_top_level_defaults_and_override() {
|
|||
let libera = &cfgs[0];
|
||||
assert_eq!(libera.name, "libera");
|
||||
assert_eq!(libera.server, "irc.libera.chat");
|
||||
assert_eq!(libera.nick, "shared"); // inherited
|
||||
assert_eq!(libera.channels, vec!["#lobby"]); // inherited
|
||||
assert_eq!(libera.nick, "shared");
|
||||
assert_eq!(libera.channels, vec!["#lobby"]);
|
||||
assert!(libera.tls);
|
||||
assert_eq!(libera.port, 6697); // TLS-port convention applied per network
|
||||
assert_eq!(libera.port, 6697);
|
||||
|
||||
let oftc = &cfgs[1];
|
||||
assert_eq!(oftc.name, "oftc");
|
||||
assert_eq!(oftc.server, "irc.oftc.net");
|
||||
assert_eq!(oftc.nick, "other"); // overridden
|
||||
assert_eq!(oftc.channels, vec!["#oftc"]); // overridden
|
||||
assert!(!oftc.tls); // default
|
||||
assert_eq!(oftc.nick, "other");
|
||||
assert_eq!(oftc.channels, vec!["#oftc"]);
|
||||
assert!(!oftc.tls);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -48,8 +44,7 @@ fn a_section_may_rename_itself() {
|
|||
|
||||
#[test]
|
||||
fn comments_and_blanks_are_ignored() {
|
||||
// A lone commented/blank file yields the built-in default single network.
|
||||
let cfgs = parse_str("# comment\n; also\n\n \n");
|
||||
assert_eq!(cfgs.len(), 1);
|
||||
assert_eq!(cfgs[0].server, "irc.tchatou.fr"); // built-in default
|
||||
assert_eq!(cfgs[0].server, "irc.tchatou.fr");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,3 @@
|
|||
//! Unit tests for feature modules — constructed directly and driven through the
|
||||
//! public `Module` trait, with no network. This is the payoff of the module
|
||||
//! system: features are testable in isolation.
|
||||
|
||||
use rustbot::bot::module::{Action, Command, Module};
|
||||
use rustbot::bot::modules::{builtins::Builtins, dice::Dice};
|
||||
|
||||
|
|
@ -9,7 +5,6 @@ fn cmd<'a>(name: &'a str, args: &'a [&'a str]) -> Command<'a> {
|
|||
Command { sender: "alice", reply_to: "#chan", name, args, prefix: ">", network: "test" }
|
||||
}
|
||||
|
||||
/// Assert the module produced exactly one reply and return its text.
|
||||
fn reply(actions: &[Action]) -> &str {
|
||||
match actions {
|
||||
[Action::Reply(s)] => s,
|
||||
|
|
@ -47,7 +42,6 @@ fn dice_2d6_total_is_in_range() {
|
|||
let mut d = Dice::new();
|
||||
for _ in 0..300 {
|
||||
let r = reply(&d.on_command(&cmd("roll", &["2d6"]))).to_string();
|
||||
// Format: "2d6: a + b = total"
|
||||
let total: u64 = r.rsplit('=').next().unwrap().trim().parse().unwrap();
|
||||
assert!((2..=12).contains(&total), "2d6 total {total} out of range: {r:?}");
|
||||
}
|
||||
|
|
@ -57,7 +51,6 @@ fn dice_2d6_total_is_in_range() {
|
|||
fn dice_defaults_to_1d6() {
|
||||
let mut d = Dice::new();
|
||||
let r = reply(&d.on_command(&cmd("roll", &[]))).to_string();
|
||||
// Format: "1d6: N"
|
||||
assert!(r.starts_with("1d6: "), "unexpected format: {r:?}");
|
||||
let n: u64 = r.rsplit(':').next().unwrap().trim().parse().unwrap();
|
||||
assert!((1..=6).contains(&n), "1d6 {n} out of range: {r:?}");
|
||||
|
|
@ -81,7 +74,6 @@ fn dice_rejects_garbage_with_usage() {
|
|||
#[test]
|
||||
fn dice_rejects_out_of_bounds() {
|
||||
let mut d = Dice::new();
|
||||
// 999 dice exceeds the cap; 1-sided die is below the minimum.
|
||||
assert!(reply(&d.on_command(&cmd("roll", &["999d6"]))).contains("usage"));
|
||||
assert!(reply(&d.on_command(&cmd("roll", &["1d1"]))).contains("usage"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
//! Integration tests for the IRC protocol layer, exercising the public
|
||||
//! `rustbot::irc` API: message parsing, IRCv3 tags, base64, and server-time.
|
||||
|
||||
use rustbot::irc::{base64_encode, parse_server_time, Message};
|
||||
|
||||
#[test]
|
||||
|
|
@ -39,7 +36,6 @@ fn parses_numeric_reply() {
|
|||
|
||||
#[test]
|
||||
fn full_prefix_is_split() {
|
||||
// Prefix parsing is exercised through the public `Message::parse`.
|
||||
let m = Message::parse(":nick!user@host.example PRIVMSG #c :hi").unwrap();
|
||||
let p = m.prefix.expect("prefix present");
|
||||
assert_eq!(p.nick.as_deref(), Some("nick"));
|
||||
|
|
@ -59,7 +55,6 @@ fn base64_matches_known_vectors() {
|
|||
assert_eq!(base64_encode(b"f"), "Zg==");
|
||||
assert_eq!(base64_encode(b"fo"), "Zm8=");
|
||||
assert_eq!(base64_encode(b"foobar"), "Zm9vYmFy");
|
||||
// A SASL PLAIN payload: authzid="" authcid="me" passwd="pw"
|
||||
assert_eq!(base64_encode(b"\0me\0pw"), "AG1lAHB3");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue