Make store list work.

This commit is contained in:
Jeff Baskin 2023-06-25 10:39:14 -04:00
parent c26089caed
commit 933d48a47c

View File

@ -32,7 +32,12 @@ impl Store {
} }
pub fn list(&self) -> Vec<String> { pub fn list(&self) -> Vec<String> {
Vec::new() let mut names = Vec::new();
for name in self.data.keys() {
names.push(name.to_string());
}
names.sort();
names
} }
} }
@ -90,4 +95,15 @@ mod storage {
None => Ok(()), None => Ok(()),
} }
} }
#[test]
fn get_list() {
let mut store = Store::new();
let mut ids = ["one", "two", "three", "four", "five"];
for name in ids {
store.add(name.to_string()).unwrap();
}
ids.sort();
assert_eq!(store.list(), ids);
}
} }