Skip to content

Commit 089dd68

Browse files
committed
test: migrate search to snapbox
1 parent 7dcf764 commit 089dd68

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

tests/testsuite/search.rs

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
//! Tests for the `cargo search` command.
22
3-
#![allow(deprecated)]
4-
53
use cargo::util::cache_lock::CacheLockMode;
64
use cargo_test_support::cargo_process;
75
use cargo_test_support::paths;
86
use cargo_test_support::registry::{RegistryBuilder, Response};
7+
use cargo_test_support::str;
98
use std::collections::HashSet;
109

1110
const SEARCH_API_RESPONSE: &[u8] = br#"
@@ -113,8 +112,8 @@ fn not_update() {
113112

114113
cargo_process("search postgres")
115114
.replace_crates_io(registry.index_url())
116-
.with_stdout_contains(SEARCH_RESULTS)
117-
.with_stderr("") // without "Updating ... index"
115+
.with_stdout_data(SEARCH_RESULTS)
116+
.with_stderr_data("") // without "Updating ... index"
118117
.run();
119118
}
120119

@@ -124,8 +123,11 @@ fn replace_default() {
124123

125124
cargo_process("search postgres")
126125
.replace_crates_io(registry.index_url())
127-
.with_stdout_contains(SEARCH_RESULTS)
128-
.with_stderr_contains("[..]Updating [..] index")
126+
.with_stdout_data(SEARCH_RESULTS)
127+
.with_stderr_data(str![[r#"
128+
[UPDATING] crates.io index
129+
130+
"#]])
129131
.run();
130132
}
131133

@@ -135,7 +137,7 @@ fn simple() {
135137

136138
cargo_process("search postgres --index")
137139
.arg(registry.index_url().as_str())
138-
.with_stdout_contains(SEARCH_RESULTS)
140+
.with_stdout_data(SEARCH_RESULTS)
139141
.run();
140142
}
141143

@@ -145,7 +147,7 @@ fn multiple_query_params() {
145147

146148
cargo_process("search postgres sql --index")
147149
.arg(registry.index_url().as_str())
148-
.with_stdout_contains(SEARCH_RESULTS)
150+
.with_stdout_data(SEARCH_RESULTS)
149151
.run();
150152
}
151153

@@ -155,10 +157,11 @@ fn ignore_quiet() {
155157

156158
cargo_process("search -q postgres")
157159
.replace_crates_io(registry.index_url())
158-
.with_stdout_contains(SEARCH_RESULTS)
160+
.with_stdout_data(SEARCH_RESULTS)
159161
.run();
160162
}
161163

164+
#[allow(deprecated)]
162165
#[cargo_test]
163166
fn colored_results() {
164167
let registry = setup().build();
@@ -170,7 +173,13 @@ fn colored_results() {
170173

171174
cargo_process("search --color=always postgres")
172175
.replace_crates_io(registry.index_url())
173-
.with_stdout_contains("[..]\x1b[[..]")
176+
.with_stdout_data(
177+
"\
178+
...
179+
[..]\x1b[[..]
180+
...
181+
",
182+
)
174183
.run();
175184
}
176185

@@ -181,7 +190,12 @@ fn auth_required_failure() {
181190
cargo_process("search postgres")
182191
.replace_crates_io(server.index_url())
183192
.with_status(101)
184-
.with_stderr_contains("[ERROR] no token found, please run `cargo login`")
193+
.with_stderr_data(str![[r#"
194+
[UPDATING] crates.io index
195+
[ERROR] no token found, please run `cargo login`
196+
or use environment variable CARGO_REGISTRY_TOKEN
197+
198+
"#]])
185199
.run();
186200
}
187201

@@ -191,6 +205,6 @@ fn auth_required() {
191205

192206
cargo_process("search postgres")
193207
.replace_crates_io(server.index_url())
194-
.with_stdout_contains(SEARCH_RESULTS)
208+
.with_stdout_data(SEARCH_RESULTS)
195209
.run();
196210
}

0 commit comments

Comments
 (0)