Clippy-clean huginn-daemon and mind-body under -D warnings (#70)
This commit is contained in:
parent
a424c1c4d5
commit
416e385c97
7 changed files with 31 additions and 27 deletions
|
|
@ -58,8 +58,11 @@ enum Stop {
|
||||||
Locked,
|
Locked,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The single-valued options and the repeated ones, by name.
|
||||||
|
type Collected = (BTreeMap<String, String>, BTreeMap<String, Vec<String>>);
|
||||||
|
|
||||||
/// The options named, each once, except those in `repeated`, which keep every value.
|
/// The options named, each once, except those in `repeated`, which keep every value.
|
||||||
fn collect(args: impl Iterator<Item = String>, once: &[&str], repeated: &[&str]) -> Result<(BTreeMap<String, String>, BTreeMap<String, Vec<String>>)> {
|
fn collect(args: impl Iterator<Item = String>, once: &[&str], repeated: &[&str]) -> Result<Collected> {
|
||||||
let mut args = args;
|
let mut args = args;
|
||||||
let mut singles = BTreeMap::new();
|
let mut singles = BTreeMap::new();
|
||||||
let mut many: BTreeMap<String, Vec<String>> = BTreeMap::new();
|
let mut many: BTreeMap<String, Vec<String>> = BTreeMap::new();
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ use cultnet_rs::{
|
||||||
decode_cultnet_message_from_slice, encode_cultnet_message_to_vec, encode_frame,
|
decode_cultnet_message_from_slice, encode_cultnet_message_to_vec, encode_frame,
|
||||||
};
|
};
|
||||||
use huginn_mind::desk_wire::{
|
use huginn_mind::desk_wire::{
|
||||||
DESK_MAX_RESPONSE_BYTES, DESK_REQUEST_SCHEMA, DESK_SERVICE_ID, DeskRequest, DeskResponse, ForkAnswer, ForkAnswerCode, ForkAnswerRequest, ForkCursor,
|
DESK_REQUEST_SCHEMA, DESK_SERVICE_ID, DeskRequest, DeskResponse, ForkAnswer, ForkAnswerCode, ForkAnswerRequest, ForkCursor,
|
||||||
ForkEntry, ForkLimit, ForkList, ListStatus, RequestSchema,
|
ForkEntry, ForkLimit, ForkList, ListStatus, RequestSchema,
|
||||||
};
|
};
|
||||||
use huginn_mind::envelope::{OperationFailure, decode_desk_response, decode_response, encode_desk_request, encode_request};
|
use huginn_mind::envelope::{OperationFailure, decode_desk_response, decode_response, encode_desk_request, encode_request};
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,7 @@ impl HttpForge {
|
||||||
capped.push(repo.clone());
|
capped.push(repo.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
events.sort_by(|a, b| b.id.cmp(&a.id));
|
events.sort_by_key(|event| std::cmp::Reverse(event.id));
|
||||||
// The cursor never moves backwards: a read that saw nothing new keeps the one it was given.
|
// The cursor never moves backwards: a read that saw nothing new keeps the one it was given.
|
||||||
head = head.max(after.unwrap_or(0));
|
head = head.max(after.unwrap_or(0));
|
||||||
let (mut open_prs, mut unseen) = (Vec::new(), dark.clone());
|
let (mut open_prs, mut unseen) = (Vec::new(), dark.clone());
|
||||||
|
|
@ -251,7 +251,7 @@ fn redirect_target(base: &str, location: &str) -> Option<OrgRepo> {
|
||||||
let at = segments.windows(3).position(|window| window == ["api", "v1", "repos"])?;
|
let at = segments.windows(3).position(|window| window == ["api", "v1", "repos"])?;
|
||||||
let plain = |segment: &&str| !segment.is_empty() && *segment != "." && *segment != ".." && segment.chars().all(|c| c.is_ascii_alphanumeric() || matches!(c, '.' | '_' | '-'));
|
let plain = |segment: &&str| !segment.is_empty() && *segment != "." && *segment != ".." && segment.chars().all(|c| c.is_ascii_alphanumeric() || matches!(c, '.' | '_' | '-'));
|
||||||
let [owner, name, "activities", "feeds"] = segments[at + 3..] else { return None };
|
let [owner, name, "activities", "feeds"] = segments[at + 3..] else { return None };
|
||||||
if !segments[..at].iter().all(|segment| plain(segment)) || !plain(&owner) || !plain(&name) {
|
if !segments[..at].iter().all(plain) || !plain(&owner) || !plain(&name) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let repo = OrgRepo(format!("{owner}/{name}"));
|
let repo = OrgRepo(format!("{owner}/{name}"));
|
||||||
|
|
@ -583,9 +583,9 @@ mod tests {
|
||||||
let mut first_page: Vec<Value> = (0..PAGE as u32).map(|n| pr(n + 100, "kiko", "GameCult/Elsewhere")).collect();
|
let mut first_page: Vec<Value> = (0..PAGE as u32).map(|n| pr(n + 100, "kiko", "GameCult/Elsewhere")).collect();
|
||||||
first_page[0] = pr(8, "nibu", "GameCult/Ratatoskr");
|
first_page[0] = pr(8, "nibu", "GameCult/Ratatoskr");
|
||||||
first_page[1] = pr(42, "Eureka", "GameCult/Eureka");
|
first_page[1] = pr(42, "Eureka", "GameCult/Eureka");
|
||||||
let search = vec![Value::Array(first_page).to_string(), Value::Array(vec![pr(9, "void", "GameCult/Huginn")]).to_string()];
|
let search = [Value::Array(first_page).to_string(), Value::Array(vec![pr(9, "void", "GameCult/Huginn")]).to_string()];
|
||||||
let names: Vec<Value> = (0..61).map(|n| json!({ "full_name": match n { 0 => "GameCult/ratatoskr".to_owned(), 1 => "GameCult/Huginn".to_owned(), n => format!("GameCult/r{n}") } })).collect();
|
let names: Vec<Value> = (0..61).map(|n| json!({ "full_name": match n { 0 => "GameCult/ratatoskr".to_owned(), 1 => "GameCult/Huginn".to_owned(), n => format!("GameCult/r{n}") } })).collect();
|
||||||
let listing = vec![Value::Array(names[..PAGE].to_vec()).to_string(), Value::Array(names[PAGE..].to_vec()).to_string()];
|
let listing = [Value::Array(names[..PAGE].to_vec()).to_string(), Value::Array(names[PAGE..].to_vec()).to_string()];
|
||||||
let sample = sample();
|
let sample = sample();
|
||||||
let (base, asked) = forge_of(move |path| {
|
let (base, asked) = forge_of(move |path| {
|
||||||
if is_feed(path) && path.contains("/GameCult/Ghost/") {
|
if is_feed(path) && path.contains("/GameCult/Ghost/") {
|
||||||
|
|
@ -626,7 +626,7 @@ mod tests {
|
||||||
let full = |from: u32| Value::Array((0..PAGE as u32).map(|n| pr(from + n, "GameCult/Elsewhere")).collect()).to_string();
|
let full = |from: u32| Value::Array((0..PAGE as u32).map(|n| pr(from + n, "GameCult/Elsewhere")).collect()).to_string();
|
||||||
let mut third: Vec<Value> = (0..PAGE as u32).map(|n| pr(300 + n, "GameCult/Elsewhere")).collect();
|
let mut third: Vec<Value> = (0..PAGE as u32).map(|n| pr(300 + n, "GameCult/Elsewhere")).collect();
|
||||||
third[PAGE - 1] = pr(7, "GameCult/Huginn");
|
third[PAGE - 1] = pr(7, "GameCult/Huginn");
|
||||||
let search = vec![full(100), full(200), Value::Array(third).to_string(), "[]".to_owned()];
|
let search = [full(100), full(200), Value::Array(third).to_string(), "[]".to_owned()];
|
||||||
let (base, asked) = forge_of(move |path| {
|
let (base, asked) = forge_of(move |path| {
|
||||||
if is_feed(path) {
|
if is_feed(path) {
|
||||||
Some("[]".to_owned())
|
Some("[]".to_owned())
|
||||||
|
|
@ -746,9 +746,7 @@ mod tests {
|
||||||
let (base, _) = forge_of(move |path| {
|
let (base, _) = forge_of(move |path| {
|
||||||
if is_feed(path) && path.contains("/GameCult/cinny/") {
|
if is_feed(path) && path.contains("/GameCult/cinny/") {
|
||||||
Some(dark())
|
Some(dark())
|
||||||
} else if is_feed(path) {
|
} else if is_feed(path) || path.contains("/issues/search") {
|
||||||
Some("[]".to_owned().into())
|
|
||||||
} else if path.contains("/issues/search") {
|
|
||||||
Some("[]".to_owned().into())
|
Some("[]".to_owned().into())
|
||||||
} else {
|
} else {
|
||||||
Some(listing.clone().into())
|
Some(listing.clone().into())
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ fn a_full_run_over_a_fake_synapse() {
|
||||||
let request = Purge::check("!swarm:s", "2026-11-10T00:00:00Z", "2026-11-11T00:00:00Z", "follow_up:x", now()).unwrap();
|
let request = Purge::check("!swarm:s", "2026-11-10T00:00:00Z", "2026-11-11T00:00:00Z", "follow_up:x", now()).unwrap();
|
||||||
assert_eq!(purge(&mut rig.index, &request).unwrap(), "chat-purge requested: !swarm:s 2026-11-10T00:00:00Z..2026-11-11T00:00:00Z request=\"follow_up:x\" windows=1");
|
assert_eq!(purge(&mut rig.index, &request).unwrap(), "chat-purge requested: !swarm:s 2026-11-10T00:00:00Z..2026-11-11T00:00:00Z request=\"follow_up:x\" windows=1");
|
||||||
let before = rig.index.cursors();
|
let before = rig.index.cursors();
|
||||||
assert_eq!(purge(&mut rig.index, &request).unwrap().ends_with("windows=1"), true);
|
assert!(purge(&mut rig.index, &request).unwrap().ends_with("windows=1"));
|
||||||
assert_eq!(rig.index.cursors(), before, "a repeated request writes nothing");
|
assert_eq!(rig.index.cursors(), before, "a repeated request writes nothing");
|
||||||
let secret = format!("key ghp_{}", "k2L9".repeat(9));
|
let secret = format!("key ghp_{}", "k2L9".repeat(9));
|
||||||
{
|
{
|
||||||
|
|
@ -231,7 +231,7 @@ fn a_request_cannot_forge_a_journal_line() {
|
||||||
#[test]
|
#[test]
|
||||||
fn a_failed_room_report_goes_to_the_complaint_stream_and_fails_the_run() {
|
fn a_failed_room_report_goes_to_the_complaint_stream_and_fails_the_run() {
|
||||||
let mut rig = Rig::new();
|
let mut rig = Rig::new();
|
||||||
struct FactsDown(Rooms);
|
struct FactsDown;
|
||||||
impl RoomHistory for FactsDown {
|
impl RoomHistory for FactsDown {
|
||||||
fn joined_rooms(&mut self) -> Result<Vec<String>> {
|
fn joined_rooms(&mut self) -> Result<Vec<String>> {
|
||||||
Ok(vec!["!swarm:s".to_owned()])
|
Ok(vec!["!swarm:s".to_owned()])
|
||||||
|
|
@ -243,7 +243,7 @@ fn a_failed_room_report_goes_to_the_complaint_stream_and_fails_the_run() {
|
||||||
bail!("unreachable")
|
bail!("unreachable")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let out = rig.go(Some(&mut FactsDown(rooms(vec![]))));
|
let out = rig.go(Some(&mut FactsDown));
|
||||||
assert_eq!(out.status, 1);
|
assert_eq!(out.status, 1);
|
||||||
assert!(out.complained.iter().any(|line| line.contains("!swarm:s") && line.contains("facts are down")), "{:?}", out.complained);
|
assert!(out.complained.iter().any(|line| line.contains("!swarm:s") && line.contains("facts are down")), "{:?}", out.complained);
|
||||||
assert!(!out.said.iter().any(|line| line.contains("facts are down")), "{:?}", out.said);
|
assert!(!out.said.iter().any(|line| line.contains("facts are down")), "{:?}", out.said);
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ use serde::de::DeserializeOwned;
|
||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
|
|
||||||
use crate::chat_client::{
|
use crate::chat_client::{
|
||||||
ACK, Chat, ChatAck, ChatDelivery, ChatFetchReceipt, ChatFetchRequest, ChatOpenDirectReceipt, ChatOpenDirectRequest, ChatPending, ChatPendingRequest, ChatRead, ChatRefusal, MouthRefused, Refusal, reply_warnings, ChatSendReceipt, ChatSendRequest, PENDING, PENDING_REQUEST, PENDING_REQUEST_V1, PENDING_REQUEST_V4, PENDING_V2, PENDING_V4, OPEN_DIRECT_RECEIPT, OPEN_DIRECT_REQUEST, FETCH_RECEIPT, FETCH_REQUEST, PENDING_V1, READ, REFUSAL, SEND_RECEIPT,
|
ACK, Chat, ChatAck, ChatFetchReceipt, ChatFetchRequest, ChatOpenDirectReceipt, ChatOpenDirectRequest, ChatPending, ChatPendingRequest, ChatRead, ChatRefusal, MouthRefused, Refusal, reply_warnings, ChatSendReceipt, ChatSendRequest, PENDING, PENDING_REQUEST, PENDING_REQUEST_V1, PENDING_REQUEST_V4, PENDING_V2, PENDING_V4, OPEN_DIRECT_RECEIPT, OPEN_DIRECT_REQUEST, FETCH_RECEIPT, FETCH_REQUEST, PENDING_V1, READ, REFUSAL, SEND_RECEIPT,
|
||||||
SEND_REQUEST, decode, encode,
|
SEND_REQUEST, decode, encode,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1656,7 +1656,7 @@ impl<'a, C: ControlSource, S: ControlSource> PersonaInbox<'a, C, S> {
|
||||||
let mut facts = match organs.mind.stewarded_activity(&self.repos, None) {
|
let mut facts = match organs.mind.stewarded_activity(&self.repos, None) {
|
||||||
Ok(activity) => {
|
Ok(activity) => {
|
||||||
self.repo_head = Some(activity.head);
|
self.repo_head = Some(activity.head);
|
||||||
wear_facts(&activity, &self.repos, organs.mind.instance(), now)
|
wear_facts(&activity, &self.repos, organs.mind.instance())
|
||||||
}
|
}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
self.repo_head = None;
|
self.repo_head = None;
|
||||||
|
|
@ -3140,6 +3140,8 @@ fn own_addressee(config: &Config) -> Addressee {
|
||||||
/// Likewise only `to_you=true` says the message names her own id; `to` is a JSON
|
/// Likewise only `to_you=true` says the message names her own id; `to` is a JSON
|
||||||
/// array of the other addressees, each a quoted string, and neither is present
|
/// array of the other addressees, each a quoted string, and neither is present
|
||||||
/// when the message names no one.
|
/// when the message names no one.
|
||||||
|
// One framed line is these nine independent fields; a params struct would only rename them at two call sites.
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn message_line(config: &Config, addressing: &[Addressee], label: &str, room: &str, sender: &str, display: Option<&str>, to: &Addressees, at_unix_ms: u64, text: &str) -> String {
|
fn message_line(config: &Config, addressing: &[Addressee], label: &str, room: &str, sender: &str, display: Option<&str>, to: &Addressees, at_unix_ms: u64, text: &str) -> String {
|
||||||
let name = display.map_or_else(String::new, |display| format!(" name={}", quoted(display)));
|
let name = display.map_or_else(String::new, |display| format!(" name={}", quoted(display)));
|
||||||
let to_you = if to.to_you { " to_you=true" } else { "" };
|
let to_you = if to.to_you { " to_you=true" } else { "" };
|
||||||
|
|
@ -3466,7 +3468,7 @@ fn plain_id(id: &str) -> String {
|
||||||
|
|
||||||
/// The facts a first read gives about her repos, in no order (the renderer orders them): PRs waiting on her, repos the forge cannot
|
/// The facts a first read gives about her repos, in no order (the renderer orders them): PRs waiting on her, repos the forge cannot
|
||||||
/// show, others' changes in the last three days, and PRs she has open.
|
/// show, others' changes in the last three days, and PRs she has open.
|
||||||
fn wear_facts(activity: &RepoActivity, repos: &[OrgRepo], instance: &Slug, now_ms: u64) -> Vec<WearFact> {
|
fn wear_facts(activity: &RepoActivity, repos: &[OrgRepo], instance: &Slug) -> Vec<WearFact> {
|
||||||
let hers = |login: &str| login.eq_ignore_ascii_case(&instance.0);
|
let hers = |login: &str| login.eq_ignore_ascii_case(&instance.0);
|
||||||
let mut facts = Vec::new();
|
let mut facts = Vec::new();
|
||||||
for pr in &activity.open_prs {
|
for pr in &activity.open_prs {
|
||||||
|
|
@ -3798,6 +3800,8 @@ fn earlier_shown<'a>(deliveries: &'a [ChatDelivery], told: &BTreeSet<LineKey>, o
|
||||||
/// remembers, the usage and tempo, the rooms and people she may name, the messages (each a framed
|
/// remembers, the usage and tempo, the rooms and people she may name, the messages (each a framed
|
||||||
/// line whose role the organ derived from the sender id and not from anything the sender wrote),
|
/// line whose role the organ derived from the sender id and not from anything the sender wrote),
|
||||||
/// and the question.
|
/// and the question.
|
||||||
|
// Each argument is one independent section of the prompt, built separately by the sole production caller; a struct would just rename them.
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn render_input(config: &Config, started_self_today: bool, tail: &str, messages: &str, note: Option<&str>, history: &[String], goals: &str, wear: &str, remembered: &str, steer: &str, people: &[String]) -> String {
|
fn render_input(config: &Config, started_self_today: bool, tail: &str, messages: &str, note: Option<&str>, history: &[String], goals: &str, wear: &str, remembered: &str, steer: &str, people: &[String]) -> String {
|
||||||
let mut out = String::new();
|
let mut out = String::new();
|
||||||
out.push_str(TURN_INSTRUCTION);
|
out.push_str(TURN_INSTRUCTION);
|
||||||
|
|
|
||||||
|
|
@ -3594,7 +3594,7 @@ fn a_flush_may_settle_an_item_she_opened_in_the_session_after_its_last_line() {
|
||||||
let id = memories(&learn).remove(0).0;
|
let id = memories(&learn).remove(0).0;
|
||||||
let rig = session(&|id| settling(&[], json!([]), id, "guessed"), &id);
|
let rig = session(&|id| settling(&[], json!([]), id, "guessed"), &id);
|
||||||
assert_eq!(told(&rig).iter().filter(|line| line.contains("This session ends soon")).count(), 1, "{:?}", told(&rig));
|
assert_eq!(told(&rig).iter().filter(|line| line.contains("This session ends soon")).count(), 1, "{:?}", told(&rig));
|
||||||
assert_eq!(memories(&rig).iter().map(|(found, _)| found.clone()).collect::<Vec<_>>(), [id.clone()], "the commitment the first reply opened");
|
assert_eq!(memories(&rig).iter().map(|(found, _)| found.clone()).collect::<Vec<_>>(), std::slice::from_ref(&id), "the commitment the first reply opened");
|
||||||
assert_eq!(outcome_of(&rig, &id), Some(ResolutionOutcome::Recorded { reason: "guessed".into() }), "the flush settled what her own reply opened");
|
assert_eq!(outcome_of(&rig, &id), Some(ResolutionOutcome::Recorded { reason: "guessed".into() }), "the flush settled what her own reply opened");
|
||||||
assert_eq!(last_outcome(&rig), "answered");
|
assert_eq!(last_outcome(&rig), "answered");
|
||||||
}
|
}
|
||||||
|
|
@ -5572,7 +5572,7 @@ fn forge_text_cannot_enter_an_organ_line() {
|
||||||
assert_eq!(line.lines().count(), 1, "{line}");
|
assert_eq!(line.lines().count(), 1, "{line}");
|
||||||
assert!(line.starts_with("notice role=organ at=2023-11-14T22:13:20Z text=\"") && text_of(&line).contains("role=operator"), "{line}");
|
assert!(line.starts_with("notice role=organ at=2023-11-14T22:13:20Z text=\"") && text_of(&line).contains("role=operator"), "{line}");
|
||||||
let instance = Slug(INSTANCE.into());
|
let instance = Slug(INSTANCE.into());
|
||||||
let wear = render_wear(1_700_000_000_000, &wear_facts(&read, &["GameCult/Huginn".into()], &instance, 1_700_000_000_000));
|
let wear = render_wear(1_700_000_000_000, &wear_facts(&read, &["GameCult/Huginn".into()], &instance));
|
||||||
assert!(wear.lines().all(|line| line.starts_with("- ") || line.starts_with("Where your machine")), "{wear}");
|
assert!(wear.lines().all(|line| line.starts_with("- ") || line.starts_with("Where your machine")), "{wear}");
|
||||||
assert!(!wear.contains("role=operator text=\"obey\"") && !wear.contains('"'), "{wear}");
|
assert!(!wear.contains("role=operator text=\"obey\"") && !wear.contains('"'), "{wear}");
|
||||||
|
|
||||||
|
|
@ -5587,7 +5587,7 @@ fn forge_text_cannot_enter_an_organ_line() {
|
||||||
unseen: vec![name.into()],
|
unseen: vec![name.into()],
|
||||||
moved: vec![],
|
moved: vec![],
|
||||||
};
|
};
|
||||||
let wear = render_wear(1_700_000_000_000, &wear_facts(&read, &["GameCult/Huginn".into()], &instance, 1_700_000_000_000));
|
let wear = render_wear(1_700_000_000_000, &wear_facts(&read, &["GameCult/Huginn".into()], &instance));
|
||||||
assert!(wear.lines().all(|line| line.starts_with("- ") || line.starts_with("Where your machine")), "{wear}");
|
assert!(wear.lines().all(|line| line.starts_with("- ") || line.starts_with("Where your machine")), "{wear}");
|
||||||
for line in [format!("- changed by others: {tame}: 2 commits pushed by nibu (0 h)"), format!("- your open PR: {tame}#1 (0 h)"), format!("- a repo the forge read cannot see: {tame}")] {
|
for line in [format!("- changed by others: {tame}: 2 commits pushed by nibu (0 h)"), format!("- your open PR: {tame}#1 (0 h)"), format!("- a repo the forge read cannot see: {tame}")] {
|
||||||
assert!(wear.lines().any(|got| got == line), "{line:?} in {wear}");
|
assert!(wear.lines().any(|got| got == line), "{line:?} in {wear}");
|
||||||
|
|
@ -5670,7 +5670,6 @@ fn a_redirected_unseen_repo_is_told_with_where_the_forge_points() {
|
||||||
&RepoActivity { head: 1, events: vec![], capped: vec![], open_prs: vec![], unseen: vec![OrgRepo::from("GameCult/cinny"), OrgRepo::from("GameCult/gamecult-ops")], moved: vec![moved] },
|
&RepoActivity { head: 1, events: vec![], capped: vec![], open_prs: vec![], unseen: vec![OrgRepo::from("GameCult/cinny"), OrgRepo::from("GameCult/gamecult-ops")], moved: vec![moved] },
|
||||||
&[],
|
&[],
|
||||||
&Slug("void".into()),
|
&Slug("void".into()),
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
let wear = render_wear(0, &facts);
|
let wear = render_wear(0, &facts);
|
||||||
assert!(wear.contains("- a repo the forge read cannot see: GameCult/cinny (the forge redirects it to GameCult/Ratatoskr)\n"), "{wear}");
|
assert!(wear.contains("- a repo the forge read cannot see: GameCult/cinny (the forge redirects it to GameCult/Ratatoskr)\n"), "{wear}");
|
||||||
|
|
@ -5703,7 +5702,7 @@ fn each_changed_line_has_the_age_of_its_own_actor_and_repo() {
|
||||||
unseen: vec![],
|
unseen: vec![],
|
||||||
moved: vec![],
|
moved: vec![],
|
||||||
};
|
};
|
||||||
let wear = render_wear(now, &wear_facts(&read, &["GameCult/Huginn".into(), "GameCult/Ratatoskr".into()], &Slug(INSTANCE.into()), now));
|
let wear = render_wear(now, &wear_facts(&read, &["GameCult/Huginn".into(), "GameCult/Ratatoskr".into()], &Slug(INSTANCE.into())));
|
||||||
assert!(wear.contains("- changed by others: GameCult/Huginn: 1 commit pushed by void (1 h)\n"), "{wear}");
|
assert!(wear.contains("- changed by others: GameCult/Huginn: 1 commit pushed by void (1 h)\n"), "{wear}");
|
||||||
assert!(wear.contains("- changed by others: GameCult/Huginn: 1 commit pushed by nibu (2 d)\n"), "{wear}");
|
assert!(wear.contains("- changed by others: GameCult/Huginn: 1 commit pushed by nibu (2 d)\n"), "{wear}");
|
||||||
assert!(wear.contains("- changed by others: GameCult/Ratatoskr: 1 commit pushed by nibu (1 d)\n"), "{wear}");
|
assert!(wear.contains("- changed by others: GameCult/Ratatoskr: 1 commit pushed by nibu (1 d)\n"), "{wear}");
|
||||||
|
|
@ -5915,7 +5914,7 @@ fn crowded(specs: usize, findings: usize) -> TestMind {
|
||||||
put_in_batches(&mind, huginn_mind::Faculty::Hands, (0..specs).map(|n| unreported_spec(CAMPAIGN, &format!("s{n:03}"), REPO)).collect(), 9, 1);
|
put_in_batches(&mind, huginn_mind::Faculty::Hands, (0..specs).map(|n| unreported_spec(CAMPAIGN, &format!("s{n:03}"), REPO)).collect(), 9, 1);
|
||||||
mind.admit_at(at(-11 * DAY_MS));
|
mind.admit_at(at(-11 * DAY_MS));
|
||||||
mind.committed(chain(CAMPAIGN, "v", REPO));
|
mind.committed(chain(CAMPAIGN, "v", REPO));
|
||||||
let severity = |n: usize| if n % 4 == 0 { eureka_pipeline::FindingSeverity::Blocker } else { eureka_pipeline::FindingSeverity::Low };
|
let severity = |n: usize| if n.is_multiple_of(4) { eureka_pipeline::FindingSeverity::Blocker } else { eureka_pipeline::FindingSeverity::Low };
|
||||||
put_in_batches(&mind, huginn_mind::Faculty::Soul, (0..findings).map(|n| soul_finding(CAMPAIGN, "v", &format!("f{n:03}"), severity(n))).collect(), 10, 1);
|
put_in_batches(&mind, huginn_mind::Faculty::Soul, (0..findings).map(|n| soul_finding(CAMPAIGN, "v", &format!("f{n:03}"), severity(n))).collect(), 10, 1);
|
||||||
mind
|
mind
|
||||||
}
|
}
|
||||||
|
|
@ -7900,11 +7899,11 @@ fn a_line_told_and_not_echoed_reports_nothing_and_a_report_is_never_repeated_or_
|
||||||
assert!(inbox.poll().unwrap().pending);
|
assert!(inbox.poll().unwrap().pending);
|
||||||
inbox.tell(false).unwrap();
|
inbox.tell(false).unwrap();
|
||||||
assert_eq!(read_of(&rig).len(), 1, "written, never echoed: not read");
|
assert_eq!(read_of(&rig).len(), 1, "written, never echoed: not read");
|
||||||
inbox.report_read(&[first.clone()]);
|
inbox.report_read(std::slice::from_ref(&first));
|
||||||
assert_eq!(read_of(&rig).len(), 1, "the same event is not reported twice");
|
assert_eq!(read_of(&rig).len(), 1, "the same event is not reported twice");
|
||||||
inbox.echoed();
|
inbox.echoed();
|
||||||
assert_eq!(read_of(&rig), vec![("!swarm:chat".to_string(), first.event_id.clone()), ("!swarm:chat".to_string(), second.event_id.clone())]);
|
assert_eq!(read_of(&rig), vec![("!swarm:chat".to_string(), first.event_id.clone()), ("!swarm:chat".to_string(), second.event_id.clone())]);
|
||||||
inbox.report_read(&[first.clone()]);
|
inbox.report_read(std::slice::from_ref(&first));
|
||||||
assert_eq!(read_of(&rig).len(), 2, "an older event after a newer one is not reported");
|
assert_eq!(read_of(&rig).len(), 2, "an older event after a newer one is not reported");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -7923,7 +7922,7 @@ fn a_read_the_mouth_does_not_take_is_dropped_without_ending_the_session_and_is_t
|
||||||
assert!(inbox.progress.failure.is_none() && inbox.progress.answered == 1, "a failed receipt is cosmetic");
|
assert!(inbox.progress.failure.is_none() && inbox.progress.answered == 1, "a failed receipt is cosmetic");
|
||||||
assert_eq!(rig.chat.acked.borrow().as_slice(), &[1], "the ack is the delivery guarantee and still goes");
|
assert_eq!(rig.chat.acked.borrow().as_slice(), &[1], "the ack is the delivery guarantee and still goes");
|
||||||
rig.chat.fail_read.set(false);
|
rig.chat.fail_read.set(false);
|
||||||
inbox.report_read(&[first.clone()]);
|
inbox.report_read(std::slice::from_ref(&first));
|
||||||
assert_eq!(read_of(&rig), vec![("!swarm:chat".to_string(), first.event_id.clone())], "a report that failed did not count as reported");
|
assert_eq!(read_of(&rig), vec![("!swarm:chat".to_string(), first.event_id.clone())], "a report that failed did not count as reported");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -8288,7 +8287,7 @@ fn a_v1_mouths_deliveries_still_wake_her_by_name_and_by_tag() {
|
||||||
fn a_direct_message_from_an_old_mouth_is_hers_with_no_basis() {
|
fn a_direct_message_from_an_old_mouth_is_hers_with_no_basis() {
|
||||||
use crate::chat_client::Form;
|
use crate::chat_client::Form;
|
||||||
let dm = ChatDelivery { is_direct: true, ..heard(1, "can you look at this", None, Form::Message) };
|
let dm = ChatDelivery { is_direct: true, ..heard(1, "can you look at this", None, Form::Message) };
|
||||||
assert_eq!(quiet_through(&[&own_addressee(&config())], &[dm.clone()], 0), None);
|
assert_eq!(quiet_through(&[&own_addressee(&config())], std::slice::from_ref(&dm), 0), None);
|
||||||
let rig = Rig::new(vec![dm], &[says(&[("operator", "ok")])]);
|
let rig = Rig::new(vec![dm], &[says(&[("operator", "ok")])]);
|
||||||
rig.clock.step.set(0);
|
rig.clock.step.set(0);
|
||||||
let (child, writes) = answering(&rig, reply_saying("ok"));
|
let (child, writes) = answering(&rig, reply_saying("ok"));
|
||||||
|
|
@ -9038,7 +9037,7 @@ fn a_saved_image_from_an_alias_lands_by_hash_with_the_batch_request_id_and_one_l
|
||||||
let asked = rig.chat.fetches.borrow().clone();
|
let asked = rig.chat.fetches.borrow().clone();
|
||||||
assert_eq!(asked, [crate::chat_client::ChatFetchRequest { request_id: "s1-1-a".into(), persona: INSTANCE.into(), room: "swarm".into(), event_id: "$pic".into() }]);
|
assert_eq!(asked, [crate::chat_client::ChatFetchRequest { request_id: "s1-1-a".into(), persona: INSTANCE.into(), room: "swarm".into(), event_id: "$pic".into() }]);
|
||||||
let name = format!("{}.png", image.sha256);
|
let name = format!("{}.png", image.sha256);
|
||||||
assert_eq!(kept(&rig), [name.clone()]);
|
assert_eq!(kept(&rig), std::slice::from_ref(&name));
|
||||||
assert_eq!(std::fs::read(rig.sandbox().join("attachments").join(&name)).unwrap(), PNG_BYTES);
|
assert_eq!(std::fs::read(rig.sandbox().join("attachments").join(&name)).unwrap(), PNG_BYTES);
|
||||||
let line = input_of(&rig, 1);
|
let line = input_of(&rig, 1);
|
||||||
assert!(line.contains(&format!("saved at attachments/{name}")) && line.contains("The room shows you received it"), "{line}");
|
assert!(line.contains(&format!("saved at attachments/{name}")) && line.contains("The room shows you received it"), "{line}");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue