Skip to content

Commit ffe59de

Browse files
committed
test(overlay): Use snapshot testing
1 parent 81848c3 commit ffe59de

File tree

1 file changed

+24
-27
lines changed

1 file changed

+24
-27
lines changed

tests/testsuite/registry_overlay.rs

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use cargo_test_support::prelude::*;
44
use cargo_test_support::project;
55
use cargo_test_support::registry::{Package, RegistryBuilder, TestRegistry};
6+
use cargo_test_support::str;
67

78
fn setup() -> (TestRegistry, String) {
89
let alt = RegistryBuilder::new().alternative().build();
@@ -77,17 +78,16 @@ fn registry_version_wins() {
7778

7879
p.cargo("check")
7980
.overlay_registry(&reg.index_url(), &alt_path)
80-
.with_stderr_data(
81-
"\
82-
[UPDATING] [..]
81+
.with_stderr_data(str![[r#"
82+
[UPDATING] `sparse+http://127.0.0.1:[..]/index/` index
8383
[LOCKING] 1 package to latest compatible version
8484
[DOWNLOADING] crates ...
85-
[DOWNLOADED] baz v0.1.1 (registry [..])
85+
[DOWNLOADED] baz v0.1.1 (registry `sparse+http://127.0.0.1:[..]/index/`)
8686
[CHECKING] baz v0.1.1
8787
[CHECKING] foo v0.0.1 ([ROOT]/foo)
8888
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
89-
",
90-
)
89+
90+
"#]])
9191
.run();
9292
}
9393

@@ -120,16 +120,15 @@ fn overlay_version_wins() {
120120

121121
p.cargo("check")
122122
.overlay_registry(&reg.index_url(), &alt_path)
123-
.with_stderr_data(
124-
"\
125-
[UPDATING] [..]
123+
.with_stderr_data(str![[r#"
124+
[UPDATING] `sparse+http://127.0.0.1:[..]/index/` index
126125
[LOCKING] 1 package to latest compatible version
127-
[UNPACKING] baz v0.1.1 (registry [..])
126+
[UNPACKING] baz v0.1.1 (registry `[ROOT]/alternative-registry`)
128127
[CHECKING] baz v0.1.1
129128
[CHECKING] foo v0.0.1 ([ROOT]/foo)
130129
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
131-
",
132-
)
130+
131+
"#]])
133132
.run();
134133
}
135134

@@ -163,18 +162,17 @@ fn version_collision() {
163162
p.cargo("check")
164163
.overlay_registry(&reg.index_url(), &alt_path)
165164
.with_status(101)
166-
.with_stderr_data(
167-
"\
168-
[UPDATING] [..]
169-
[ERROR] failed to get `baz` [..]
165+
.with_stderr_data(str![[r#"
166+
[UPDATING] `sparse+http://127.0.0.1:[..]/index/` index
167+
[ERROR] failed to get `baz` as a dependency of package `foo v0.0.1 ([ROOT]/foo)`
170168
171169
Caused by:
172170
failed to query replaced source registry `crates-io`
173171
174172
Caused by:
175173
found a package in the remote registry and the local overlay: [email protected]
176-
",
177-
)
174+
175+
"#]])
178176
.run();
179177
}
180178

@@ -248,22 +246,21 @@ fn registry_dep_depends_on_new_local_package() {
248246

249247
p.cargo("check")
250248
.overlay_registry(&reg.index_url(), &alt_path)
251-
.with_stderr_data(
252-
"\
253-
[UPDATING] [..]
249+
.with_stderr_data(str![[r#"
250+
[UPDATING] `sparse+http://127.0.0.1:[..]/index/` index
254251
[LOCKING] 3 packages to latest compatible versions
255252
[ADDING] workspace-package v0.0.1 (available: v0.1.1)
256253
[DOWNLOADING] crates ...
257-
[UNPACKING] [..]
258-
[DOWNLOADED] [..]
259-
[DOWNLOADED] [..]
254+
[UNPACKING] workspace-package v0.1.1 (registry `[ROOT]/alternative-registry`)
255+
[DOWNLOADED] registry-package v0.1.0 (registry `sparse+http://127.0.0.1:[..]/index/`)
256+
[DOWNLOADED] workspace-package v0.0.1 (registry `sparse+http://127.0.0.1:[..]/index/`)
260257
[CHECKING] workspace-package v0.1.1
261258
[CHECKING] workspace-package v0.0.1
262259
[CHECKING] registry-package v0.1.0
263-
[CHECKING] foo v0.0.1 [..]
260+
[CHECKING] foo v0.0.1 ([ROOT]/foo)
264261
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
265-
",
266-
)
262+
263+
"#]])
267264
.run();
268265
}
269266

0 commit comments

Comments
 (0)