1
1
//! Tests for the `cargo search` command.
2
2
3
- #![ allow( deprecated) ]
4
-
5
3
use cargo:: util:: cache_lock:: CacheLockMode ;
6
4
use cargo_test_support:: cargo_process;
7
5
use cargo_test_support:: paths;
8
6
use cargo_test_support:: registry:: { RegistryBuilder , Response } ;
7
+ use cargo_test_support:: str;
9
8
use std:: collections:: HashSet ;
10
9
11
10
const SEARCH_API_RESPONSE : & [ u8 ] = br#"
@@ -113,8 +112,8 @@ fn not_update() {
113
112
114
113
cargo_process ( "search postgres" )
115
114
. 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"
118
117
. run ( ) ;
119
118
}
120
119
@@ -124,8 +123,11 @@ fn replace_default() {
124
123
125
124
cargo_process ( "search postgres" )
126
125
. 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
+ "# ] ] )
129
131
. run ( ) ;
130
132
}
131
133
@@ -135,7 +137,7 @@ fn simple() {
135
137
136
138
cargo_process ( "search postgres --index" )
137
139
. arg ( registry. index_url ( ) . as_str ( ) )
138
- . with_stdout_contains ( SEARCH_RESULTS )
140
+ . with_stdout_data ( SEARCH_RESULTS )
139
141
. run ( ) ;
140
142
}
141
143
@@ -145,7 +147,7 @@ fn multiple_query_params() {
145
147
146
148
cargo_process ( "search postgres sql --index" )
147
149
. arg ( registry. index_url ( ) . as_str ( ) )
148
- . with_stdout_contains ( SEARCH_RESULTS )
150
+ . with_stdout_data ( SEARCH_RESULTS )
149
151
. run ( ) ;
150
152
}
151
153
@@ -155,10 +157,11 @@ fn ignore_quiet() {
155
157
156
158
cargo_process ( "search -q postgres" )
157
159
. replace_crates_io ( registry. index_url ( ) )
158
- . with_stdout_contains ( SEARCH_RESULTS )
160
+ . with_stdout_data ( SEARCH_RESULTS )
159
161
. run ( ) ;
160
162
}
161
163
164
+ #[ allow( deprecated) ]
162
165
#[ cargo_test]
163
166
fn colored_results ( ) {
164
167
let registry = setup ( ) . build ( ) ;
@@ -170,7 +173,13 @@ fn colored_results() {
170
173
171
174
cargo_process ( "search --color=always postgres" )
172
175
. replace_crates_io ( registry. index_url ( ) )
173
- . with_stdout_contains ( "[..]\x1b [[..]" )
176
+ . with_stdout_data (
177
+ "\
178
+ ...
179
+ [..]\x1b [[..]
180
+ ...
181
+ " ,
182
+ )
174
183
. run ( ) ;
175
184
}
176
185
@@ -181,7 +190,12 @@ fn auth_required_failure() {
181
190
cargo_process ( "search postgres" )
182
191
. replace_crates_io ( server. index_url ( ) )
183
192
. 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
+ "# ] ] )
185
199
. run ( ) ;
186
200
}
187
201
@@ -191,6 +205,6 @@ fn auth_required() {
191
205
192
206
cargo_process ( "search postgres" )
193
207
. replace_crates_io ( server. index_url ( ) )
194
- . with_stdout_contains ( SEARCH_RESULTS )
208
+ . with_stdout_data ( SEARCH_RESULTS )
195
209
. run ( ) ;
196
210
}
0 commit comments