mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
test: migrate search to snapbox
This commit is contained in:
parent
7dcf764cbc
commit
089dd68d87
@ -1,11 +1,10 @@
|
|||||||
//! Tests for the `cargo search` command.
|
//! Tests for the `cargo search` command.
|
||||||
|
|
||||||
#![allow(deprecated)]
|
|
||||||
|
|
||||||
use cargo::util::cache_lock::CacheLockMode;
|
use cargo::util::cache_lock::CacheLockMode;
|
||||||
use cargo_test_support::cargo_process;
|
use cargo_test_support::cargo_process;
|
||||||
use cargo_test_support::paths;
|
use cargo_test_support::paths;
|
||||||
use cargo_test_support::registry::{RegistryBuilder, Response};
|
use cargo_test_support::registry::{RegistryBuilder, Response};
|
||||||
|
use cargo_test_support::str;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
const SEARCH_API_RESPONSE: &[u8] = br#"
|
const SEARCH_API_RESPONSE: &[u8] = br#"
|
||||||
@ -113,8 +112,8 @@ fn not_update() {
|
|||||||
|
|
||||||
cargo_process("search postgres")
|
cargo_process("search postgres")
|
||||||
.replace_crates_io(registry.index_url())
|
.replace_crates_io(registry.index_url())
|
||||||
.with_stdout_contains(SEARCH_RESULTS)
|
.with_stdout_data(SEARCH_RESULTS)
|
||||||
.with_stderr("") // without "Updating ... index"
|
.with_stderr_data("") // without "Updating ... index"
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,8 +123,11 @@ fn replace_default() {
|
|||||||
|
|
||||||
cargo_process("search postgres")
|
cargo_process("search postgres")
|
||||||
.replace_crates_io(registry.index_url())
|
.replace_crates_io(registry.index_url())
|
||||||
.with_stdout_contains(SEARCH_RESULTS)
|
.with_stdout_data(SEARCH_RESULTS)
|
||||||
.with_stderr_contains("[..]Updating [..] index")
|
.with_stderr_data(str![[r#"
|
||||||
|
[UPDATING] crates.io index
|
||||||
|
|
||||||
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +137,7 @@ fn simple() {
|
|||||||
|
|
||||||
cargo_process("search postgres --index")
|
cargo_process("search postgres --index")
|
||||||
.arg(registry.index_url().as_str())
|
.arg(registry.index_url().as_str())
|
||||||
.with_stdout_contains(SEARCH_RESULTS)
|
.with_stdout_data(SEARCH_RESULTS)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +147,7 @@ fn multiple_query_params() {
|
|||||||
|
|
||||||
cargo_process("search postgres sql --index")
|
cargo_process("search postgres sql --index")
|
||||||
.arg(registry.index_url().as_str())
|
.arg(registry.index_url().as_str())
|
||||||
.with_stdout_contains(SEARCH_RESULTS)
|
.with_stdout_data(SEARCH_RESULTS)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,10 +157,11 @@ fn ignore_quiet() {
|
|||||||
|
|
||||||
cargo_process("search -q postgres")
|
cargo_process("search -q postgres")
|
||||||
.replace_crates_io(registry.index_url())
|
.replace_crates_io(registry.index_url())
|
||||||
.with_stdout_contains(SEARCH_RESULTS)
|
.with_stdout_data(SEARCH_RESULTS)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
#[cargo_test]
|
#[cargo_test]
|
||||||
fn colored_results() {
|
fn colored_results() {
|
||||||
let registry = setup().build();
|
let registry = setup().build();
|
||||||
@ -170,7 +173,13 @@ fn colored_results() {
|
|||||||
|
|
||||||
cargo_process("search --color=always postgres")
|
cargo_process("search --color=always postgres")
|
||||||
.replace_crates_io(registry.index_url())
|
.replace_crates_io(registry.index_url())
|
||||||
.with_stdout_contains("[..]\x1b[[..]")
|
.with_stdout_data(
|
||||||
|
"\
|
||||||
|
...
|
||||||
|
[..]\x1b[[..]
|
||||||
|
...
|
||||||
|
",
|
||||||
|
)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,7 +190,12 @@ fn auth_required_failure() {
|
|||||||
cargo_process("search postgres")
|
cargo_process("search postgres")
|
||||||
.replace_crates_io(server.index_url())
|
.replace_crates_io(server.index_url())
|
||||||
.with_status(101)
|
.with_status(101)
|
||||||
.with_stderr_contains("[ERROR] no token found, please run `cargo login`")
|
.with_stderr_data(str![[r#"
|
||||||
|
[UPDATING] crates.io index
|
||||||
|
[ERROR] no token found, please run `cargo login`
|
||||||
|
or use environment variable CARGO_REGISTRY_TOKEN
|
||||||
|
|
||||||
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,6 +205,6 @@ fn auth_required() {
|
|||||||
|
|
||||||
cargo_process("search postgres")
|
cargo_process("search postgres")
|
||||||
.replace_crates_io(server.index_url())
|
.replace_crates_io(server.index_url())
|
||||||
.with_stdout_contains(SEARCH_RESULTS)
|
.with_stdout_data(SEARCH_RESULTS)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user