summaryrefslogtreecommitdiff
path: root/src/pathinfo.rs
diff options
context:
space:
mode:
authorfxqnlr <[email protected]>2024-09-06 13:47:47 +0200
committerfxqnlr <[email protected]>2024-09-06 13:47:47 +0200
commitab7f99e061e54924899b778e929dd2e17c8792d9 (patch)
tree644dc766f954b7a5e04cf7658821a5b5694f764b /src/pathinfo.rs
parent3e1cb020d5449849b37874f91cadfa4a9c878747 (diff)
downloadarbs-ab7f99e061e54924899b778e929dd2e17c8792d9.tar
arbs-ab7f99e061e54924899b778e929dd2e17c8792d9.tar.gz
arbs-ab7f99e061e54924899b778e929dd2e17c8792d9.zip
add root index and directory creation
Diffstat (limited to 'src/pathinfo.rs')
-rw-r--r--src/pathinfo.rs188
1 files changed, 94 insertions, 94 deletions
diff --git a/src/pathinfo.rs b/src/pathinfo.rs
index b0c3be4..be43b6e 100644
--- a/src/pathinfo.rs
+++ b/src/pathinfo.rs
@@ -150,97 +150,97 @@ impl LocationRoot {
150 } 150 }
151} 151}
152 152
153#[cfg(test)] 153// #[cfg(test)]
154mod tests { 154// mod tests {
155 use crate::{ 155// use crate::{
156 config::Config, 156// config::Config,
157 error::{Error, Result}, 157// error::{Error, Result},
158 pathinfo::PathInfo, 158// pathinfo::PathInfo,
159 }; 159// };
160 160//
161 use super::LocationRoot; 161// use super::LocationRoot;
162 162//
163 #[test] 163// #[test]
164 fn from_op_str() -> Result<()> { 164// fn from_op_str() -> Result<()> {
165 let mut config = Config::default(); 165// let mut config = Config::default();
166 config 166// config
167 .custom_directories 167// .custom_directories
168 .insert("test".to_string(), "/usr/local/test".to_string()); 168// .insert("test".to_string(), "/usr/local/test".to_string());
169 169//
170 let mut values: Vec<(&str, Result<LocationRoot>)> = Vec::new(); 170// let mut values: Vec<(&str, Result<LocationRoot>)> = Vec::new();
171 values.push(("u:test", Ok(LocationRoot::User("test".to_string())))); 171// values.push(("u:test", Ok(LocationRoot::User("test".to_string()))));
172 values.push(("s:", Ok(LocationRoot::SystemSettings))); 172// values.push(("s:", Ok(LocationRoot::SystemSettings)));
173 values.push(("r:", Ok(LocationRoot::Root))); 173// values.push(("r:", Ok(LocationRoot::Root)));
174 values.push(( 174// values.push((
175 "c:test", 175// "c:test",
176 Ok(LocationRoot::Custom("/usr/local/test".to_string())), 176// Ok(LocationRoot::Custom("/usr/local/test".to_string())),
177 )); 177// ));
178 values.push(("c:rest", Err(Error::CustomDirectory("rest".to_string())))); 178// values.push(("c:rest", Err(Error::CustomDirectory("rest".to_string()))));
179 values.push(("t:test/", Err(Error::InvalidIndex("t".to_string())))); 179// values.push(("t:test/", Err(Error::InvalidIndex("t".to_string()))));
180 values.push(( 180// values.push((
181 "test:test/usr", 181// "test:test/usr",
182 Err(Error::InvalidIndex("test".to_string())), 182// Err(Error::InvalidIndex("test".to_string())),
183 )); 183// ));
184 values.push(("/usr/local/test", Err(Error::NoIndex))); 184// values.push(("/usr/local/test", Err(Error::NoIndex)));
185 values.push(("c/usr/local/test", Err(Error::NoIndex))); 185// values.push(("c/usr/local/test", Err(Error::NoIndex)));
186 186//
187 for value in values { 187// for value in values {
188 print!("Testing {value:?}"); 188// print!("Testing {value:?}");
189 assert_eq!(LocationRoot::from_op_str(value.0, &config), value.1); 189// assert_eq!(LocationRoot::from_op_str(value.0, &config), value.1);
190 println!("\rTesting {value:?} ✓"); 190// println!("\rTesting {value:?} ✓");
191 } 191// }
192 192//
193 Ok(()) 193// Ok(())
194 } 194// }
195 195//
196 #[test] 196// #[test]
197 fn parse_location() -> Result<()> { 197// fn parse_location() -> Result<()> {
198 let mut config = Config::default(); 198// let mut config = Config::default();
199 config.user.push("test".to_string()); 199// config.user.push("test".to_string());
200 config 200// config
201 .custom_directories 201// .custom_directories
202 .insert("test".to_string(), "/usr/local/test".to_string()); 202// .insert("test".to_string(), "/usr/local/test".to_string());
203 203//
204 let mut values: Vec<(&str, Result<(String, LocationRoot)>)> = Vec::new(); 204// let mut values: Vec<(&str, Result<(String, LocationRoot)>)> = Vec::new();
205 values.push(( 205// values.push((
206 "~/.config/nvim", 206// "~/.config/nvim",
207 Ok(( 207// Ok((
208 ".config/nvim".to_string(), 208// ".config/nvim".to_string(),
209 LocationRoot::User("test".to_string()), 209// LocationRoot::User("test".to_string()),
210 )), 210// )),
211 )); 211// ));
212 values.push(( 212// values.push((
213 "u:test/.config/nvim", 213// "u:test/.config/nvim",
214 Ok(( 214// Ok((
215 ".config/nvim".to_string(), 215// ".config/nvim".to_string(),
216 LocationRoot::User("test".to_string()), 216// LocationRoot::User("test".to_string()),
217 )), 217// )),
218 )); 218// ));
219 values.push(( 219// values.push((
220 "r:/.config/nvim", 220// "r:/.config/nvim",
221 Ok((".config/nvim".to_string(), LocationRoot::Root)), 221// Ok((".config/nvim".to_string(), LocationRoot::Root)),
222 )); 222// ));
223 values.push(( 223// values.push((
224 "r:/.config/nvim", 224// "r:/.config/nvim",
225 Ok((".config/nvim".to_string(), LocationRoot::Root)), 225// Ok((".config/nvim".to_string(), LocationRoot::Root)),
226 )); 226// ));
227 values.push(( 227// values.push((
228 "s:/.config/nvim", 228// "s:/.config/nvim",
229 Ok((".config/nvim".to_string(), LocationRoot::SystemSettings)), 229// Ok((".config/nvim".to_string(), LocationRoot::SystemSettings)),
230 )); 230// ));
231 values.push(( 231// values.push((
232 "c:test/.config/nvim", 232// "c:test/.config/nvim",
233 Ok(( 233// Ok((
234 ".config/nvim".to_string(), 234// ".config/nvim".to_string(),
235 LocationRoot::Custom("/usr/local/test".to_string()), 235// LocationRoot::Custom("/usr/local/test".to_string()),
236 )), 236// )),
237 )); 237// ));
238 238//
239 for value in values { 239// for value in values {
240 print!("Testing {value:?}"); 240// print!("Testing {value:?}");
241 assert_eq!(PathInfo::parse_location(&value.0, &config), value.1); 241// assert_eq!(PathInfo::parse_location(&value.0, &config), value.1);
242 println!("\rTesting {value:?} ✓"); 242// println!("\rTesting {value:?} ✓");
243 } 243// }
244 Ok(()) 244// Ok(())
245 } 245// }
246} 246// }