Skip to content

Commit b605bf7

Browse files
committed
test(config): unsupported TOML types in arrays
1 parent eeb9324 commit b605bf7

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

tests/testsuite/bad_config.rs

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,86 @@ Caused by:
8181
.run();
8282
}
8383

84+
#[cargo_test]
85+
fn unsupported_types_in_array() {
86+
let p = project()
87+
.file("src/lib.rs", "")
88+
.file(
89+
".cargo/config.toml",
90+
r#"
91+
[alias]
92+
ints = [1, 2]
93+
"#,
94+
)
95+
.build();
96+
p.cargo("check")
97+
.with_status(101)
98+
.with_stderr_data(str![[r#"
99+
[ERROR] could not load Cargo configuration
100+
101+
Caused by:
102+
failed to load TOML configuration from `[ROOT]/foo/.cargo/config.toml`
103+
104+
Caused by:
105+
failed to parse config at `alias.ints[0]`
106+
107+
Caused by:
108+
expected string but found integer at index 0
109+
110+
"#]])
111+
.run();
112+
113+
p.change_file(
114+
".cargo/config.toml",
115+
r#"
116+
[alias]
117+
floats = [2.71828, 3.14159]
118+
"#,
119+
);
120+
121+
p.cargo("check")
122+
.with_status(101)
123+
.with_stderr_data(str![[r#"
124+
[ERROR] could not load Cargo configuration
125+
126+
Caused by:
127+
failed to load TOML configuration from `[ROOT]/foo/.cargo/config.toml`
128+
129+
Caused by:
130+
failed to parse config at `alias.floats[0]`
131+
132+
Caused by:
133+
expected string but found float at index 0
134+
135+
"#]])
136+
.run();
137+
138+
p.change_file(
139+
".cargo/config.toml",
140+
r#"
141+
[alias]
142+
datetimes = [07:32:00, 1979-05-27T07:32:00Z]
143+
"#,
144+
);
145+
146+
p.cargo("check")
147+
.with_status(101)
148+
.with_stderr_data(str![[r#"
149+
[ERROR] could not load Cargo configuration
150+
151+
Caused by:
152+
failed to load TOML configuration from `[ROOT]/foo/.cargo/config.toml`
153+
154+
Caused by:
155+
failed to parse config at `alias.datetimes[0]`
156+
157+
Caused by:
158+
expected string but found datetime at index 0
159+
160+
"#]])
161+
.run();
162+
}
163+
84164
#[cargo_test]
85165
fn bad3() {
86166
let registry = registry::init();

0 commit comments

Comments
 (0)