Skip to content

Commit 6e3c1ae

Browse files
committed
test(config): exercise more unsupported types
1 parent d720746 commit 6e3c1ae

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed

tests/testsuite/bad_config.rs

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,126 @@ Caused by:
5656
.run();
5757
}
5858

59+
#[cargo_test]
60+
fn unsupported_datetime() {
61+
let p = project()
62+
.file("src/lib.rs", "")
63+
.file(
64+
".cargo/config.toml",
65+
r#"
66+
[http]
67+
proxy = 1979-05-27T07:32:00Z
68+
"#,
69+
)
70+
.build();
71+
p.cargo("publish -v")
72+
.with_status(101)
73+
.with_stderr_data(str![[r#"
74+
[ERROR] could not load Cargo configuration
75+
76+
Caused by:
77+
failed to load TOML configuration from `[ROOT]/foo/.cargo/config.toml`
78+
79+
Caused by:
80+
failed to parse config at `http.proxy`
81+
82+
Caused by:
83+
found TOML configuration value of unknown type `datetime`
84+
85+
"#]])
86+
.run();
87+
}
88+
89+
#[cargo_test]
90+
fn unsupported_int_array() {
91+
let p = project()
92+
.file("src/lib.rs", "")
93+
.file(
94+
".cargo/config.toml",
95+
r#"
96+
[alias]
97+
ints = [1, 2]
98+
"#,
99+
)
100+
.build();
101+
p.cargo("check")
102+
.with_status(101)
103+
.with_stderr_data(str![[r#"
104+
[ERROR] could not load Cargo configuration
105+
106+
Caused by:
107+
failed to load TOML configuration from `[ROOT]/foo/.cargo/config.toml`
108+
109+
Caused by:
110+
failed to parse config at `alias.ints[0]`
111+
112+
Caused by:
113+
expected string but found integer at index 0
114+
115+
"#]])
116+
.run();
117+
}
118+
119+
#[cargo_test]
120+
fn unsupported_float_array() {
121+
let p = project()
122+
.file("src/lib.rs", "")
123+
.file(
124+
".cargo/config.toml",
125+
r#"
126+
[alias]
127+
floats = [2.71828, 3.14159]
128+
"#,
129+
)
130+
.build();
131+
p.cargo("check")
132+
.with_status(101)
133+
.with_stderr_data(str![[r#"
134+
[ERROR] could not load Cargo configuration
135+
136+
Caused by:
137+
failed to load TOML configuration from `[ROOT]/foo/.cargo/config.toml`
138+
139+
Caused by:
140+
failed to parse config at `alias.floats[0]`
141+
142+
Caused by:
143+
expected string but found float at index 0
144+
145+
"#]])
146+
.run();
147+
}
148+
149+
#[cargo_test]
150+
fn unsupported_datetime_array() {
151+
let p = project()
152+
.file("src/lib.rs", "")
153+
.file(
154+
".cargo/config.toml",
155+
r#"
156+
[alias]
157+
datetimes = [07:32:00, 1979-05-27T07:32:00Z]
158+
"#,
159+
)
160+
.build();
161+
p.cargo("check")
162+
.with_status(101)
163+
.with_stderr_data(str![[r#"
164+
[ERROR] could not load Cargo configuration
165+
166+
Caused by:
167+
failed to load TOML configuration from `[ROOT]/foo/.cargo/config.toml`
168+
169+
Caused by:
170+
failed to parse config at `alias.datetimes[0]`
171+
172+
Caused by:
173+
expected string but found datetime at index 0
174+
175+
"#]])
176+
.run();
177+
}
178+
59179
#[cargo_test]
60180
fn bad3() {
61181
let registry = registry::init();

0 commit comments

Comments
 (0)