From 933d48a47c2fdc6e27ac15b8aa4768cb197882ae Mon Sep 17 00:00:00 2001 From: Jeff Baskin Date: Sun, 25 Jun 2023 10:39:14 -0400 Subject: [PATCH] Make store list work. --- src/morethantext/store.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/morethantext/store.rs b/src/morethantext/store.rs index 361e1ca..735f13b 100644 --- a/src/morethantext/store.rs +++ b/src/morethantext/store.rs @@ -32,7 +32,12 @@ impl Store { } pub fn list(&self) -> Vec { - 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(()), } } + + #[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); + } }