Skip to content

Commit

Permalink
Merge pull request #354 from initiative-sh/always-assign-uuid
Browse files Browse the repository at this point in the history
Always assign UUID
  • Loading branch information
MikkelPaulson authored Sep 9, 2024
2 parents 98c0854 + d5224f6 commit 8bd6629
Show file tree
Hide file tree
Showing 67 changed files with 2,426 additions and 2,468 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Verify no mangled parens
run: if git grep ',)' '*.rs'; then exit 1; fi
- name: Run Clippy
run: cargo clippy --workspace -- --deny warnings
run: cargo clippy --workspace --tests -- --deny warnings

unit-tests:
name: Unit tests
Expand Down
20 changes: 12 additions & 8 deletions cli/src/rich/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ mod test {
selected: None,
query: "sh".into(),
};
assert_eq!(single.get_only_suggestion(), single.suggestions.get(0));
assert_eq!(single.get_only_suggestion(), single.suggestions.first());

let multiple = Autocomplete {
show_single_suggestion: true,
Expand Down Expand Up @@ -777,7 +777,7 @@ mod test {
autocomplete = autocomplete.up();
assert_eq!(
autocomplete.get_selected_suggestion(),
autocomplete.suggestions.get(0)
autocomplete.suggestions.first(),
);

autocomplete = autocomplete.up();
Expand Down Expand Up @@ -805,19 +805,19 @@ mod test {
autocomplete = autocomplete.down();
assert_eq!(
autocomplete.get_selected_suggestion(),
autocomplete.suggestions.get(0)
autocomplete.suggestions.first(),
);

autocomplete = autocomplete.down();
assert_eq!(
autocomplete.get_selected_suggestion(),
autocomplete.suggestions.get(1)
autocomplete.suggestions.get(1),
);

autocomplete = autocomplete.down();
assert_eq!(
autocomplete.get_selected_suggestion(),
autocomplete.suggestions.get(0)
autocomplete.suggestions.first(),
);
}

Expand Down Expand Up @@ -971,7 +971,9 @@ mod test {
assert_eq!(3, input.index);
assert_eq!(0, input.cursor);

input.history.last_mut().map(|s| s.push_str("foo"));
if let Some(s) = input.history.last_mut() {
s.push_str("foo");
}
input.cursor = 3;
assert_eq!(vec!["foo", "bar", "foo", "foo"], input.history);

Expand Down Expand Up @@ -1015,8 +1017,10 @@ mod test {

#[test]
fn key_esc_test() {
let mut input = Input::default();
input.search_query = Some(String::new());
let mut input = Input {
search_query: Some(String::new()),
..Default::default()
};

input.key(Key::Esc, false);
assert_eq!(None, input.search_query);
Expand Down
2 changes: 1 addition & 1 deletion core/src/app/command/alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ mod tests {
fn event_dispatcher(_event: Event) {}

fn app_meta() -> AppMeta {
AppMeta::new(NullDataStore::default(), &event_dispatcher)
AppMeta::new(NullDataStore, &event_dispatcher)
}

fn literal(
Expand Down
2 changes: 1 addition & 1 deletion core/src/app/command/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,6 @@ mod test {
fn event_dispatcher(_event: Event) {}

fn app_meta() -> AppMeta {
AppMeta::new(NullDataStore::default(), &event_dispatcher)
AppMeta::new(NullDataStore, &event_dispatcher)
}
}
17 changes: 9 additions & 8 deletions core/src/app/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ mod test {
use super::*;
use crate::app::assert_autocomplete;
use crate::storage::NullDataStore;
use crate::world::{Npc, ParsedThing};
use crate::world::npc::NpcData;
use crate::world::ParsedThing;
use crate::Event;
use tokio_test::block_on;

Expand Down Expand Up @@ -313,8 +314,8 @@ mod test {
assert_eq!(
Command::from(CommandMatches::new_canonical(CommandType::World(
WorldCommand::Create {
thing: ParsedThing {
thing: Npc::default().into(),
parsed_thing_data: ParsedThing {
thing_data: NpcData::default().into(),
unknown_words: Vec::new(),
word_count: 1,
},
Expand Down Expand Up @@ -375,15 +376,15 @@ mod test {

assert_eq!(
CommandType::World(WorldCommand::Create {
thing: ParsedThing {
thing: Npc::default().into(),
parsed_thing_data: ParsedThing {
thing_data: NpcData::default().into(),
unknown_words: Vec::new(),
word_count: 1,
},
}),
WorldCommand::Create {
thing: ParsedThing {
thing: Npc::default().into(),
parsed_thing_data: ParsedThing {
thing_data: NpcData::default().into(),
unknown_words: Vec::new(),
word_count: 1,
},
Expand All @@ -395,6 +396,6 @@ mod test {
fn event_dispatcher(_event: Event) {}

fn app_meta() -> AppMeta {
AppMeta::new(NullDataStore::default(), &event_dispatcher)
AppMeta::new(NullDataStore, &event_dispatcher)
}
}
3 changes: 2 additions & 1 deletion core/src/app/command/runnable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ pub trait Autocomplete {
async fn autocomplete(input: &str, app_meta: &AppMeta) -> Vec<AutocompleteSuggestion>;
}

#[track_caller]
#[cfg(test)]
pub fn assert_autocomplete(
expected_suggestions: &[(&'static str, &'static str)],
actual_suggestions: Vec<AutocompleteSuggestion>,
) {
let mut expected: Vec<_> = expected_suggestions
.into_iter()
.iter()
.map(|(a, b)| ((*a).into(), (*b).into()))
.collect();
expected.sort();
Expand Down
Loading

0 comments on commit 8bd6629

Please sign in to comment.