Skip to content

Commit aadf143

Browse files
committed
fix cannot find value v in this scope
1 parent 37bff8b commit aadf143

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

tests/testsuite/file_jsonc.rs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ use config::{Config, File, FileFormat, Map, Value};
66
use float_cmp::ApproxEqUlps;
77
use snapbox::{assert_data_eq, str};
88

9+
/// Returns the path to a test config file with an optional suffix.
10+
///
11+
/// # Example
12+
/// If the current file path is `/workspace/config-rs/tests/testsuite/file_jsonc.rs`:
13+
/// ```
14+
/// let path = get_config_file_path("");
15+
/// assert_eq!(path, "/workspace/config-rs/tests/testsuite/file_jsonc.jsonc");
16+
///
17+
/// let path = get_config_file_path(".extra");
18+
/// assert_eq!(path, "/workspace/config-rs/tests/testsuite/file_jsonc.extra.jsonc");
19+
/// ```
920
fn get_config_file_path(suffix: &str) -> String {
1021
let path = std::path::Path::new(file!());
1122
format!(
@@ -102,9 +113,8 @@ fn test_error_parse() {
102113
#[derive(Debug, Deserialize, PartialEq)]
103114
#[allow(non_snake_case)]
104115
struct OverrideSettings {
105-
foo: String,
106116
FOO: String,
107-
bar: String,
117+
foo: String,
108118
}
109119

110120
#[test]
@@ -117,10 +127,9 @@ fn test_override_uppercase_value_for_struct() {
117127
.build()
118128
.unwrap();
119129

120-
let settings = cfg.try_deserialize::<OverrideSettings>();
121-
// this assertion will ensure that the map has only lowercase keys
122-
assert_eq!(v.FOO, "FOO should be overridden");
123-
assert_eq!(v.foo, "I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_owned());
130+
let settings: OverrideSettings = cfg.try_deserialize().unwrap();
131+
assert_eq!(settings.FOO, "FOO should be overridden");
132+
assert_eq!(settings.foo, "I HAVE BEEN OVERRIDDEN_WITH_UPPER_CASE".to_owned());
124133
}
125134

126135
#[test]
@@ -133,8 +142,9 @@ fn test_override_lowercase_value_for_struct() {
133142
.build()
134143
.unwrap();
135144

136-
let values: OverrideSettings = cfg.try_deserialize().unwrap();
137-
assert_eq!(values.foo, "I have been overridden_with_lower_case".to_owned());
145+
let settings: OverrideSettings = cfg.try_deserialize().unwrap();
146+
assert_eq!(settings.FOO, "FOO should be overridden");
147+
assert_eq!(settings.foo, "I have been overridden_with_lower_case".to_owned());
138148
}
139149

140150
#[derive(Debug, Deserialize, PartialEq)]

0 commit comments

Comments
 (0)