summaryrefslogtreecommitdiff
path: root/src/tests/locations.rs
blob: fdbfa2b970cb4cf67970b5f15d21b48bcaa16964 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use crate::Configuration;

#[test]
fn locations() {
	super::do_tests_in_dir("location", ".locations.pom", |filename| {
		let locations = Configuration::load_path(filename)?;
		let config = Configuration::load_path(&filename.replace(".locations.pom", ".pom"))?;
		for (key, val) in &locations {
			let location = config.location(key).ok_or_else(|| {
				format!("key {key} not found in main config but it exists in the location's config")
			})?;
			let got = location.line();
			let expected = val
				.parse()
				.map_err(|_| format!("key {key} in location POM should be an integer"))?;
			if got != expected {
				Err(format!(
					"key {key} reported as being at line {got}, but it should be at line {expected}"
				))?;
			}
		}
		Ok(())
	})
}