mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Append registries
to config
This commit is contained in:
parent
75d06de80c
commit
2a4d1dc40a
@ -63,7 +63,7 @@ pub fn alt_api_url() -> Url {
|
||||
fn generate_path(name: &str) -> PathBuf {
|
||||
paths::root().join(name)
|
||||
}
|
||||
fn generate_url(name: &str) -> Url {
|
||||
pub fn generate_url(name: &str) -> Url {
|
||||
Url::from_file_path(generate_path(name)).ok().unwrap()
|
||||
}
|
||||
fn generate_dl_url(name: &str) -> String {
|
||||
@ -177,13 +177,9 @@ pub fn init() {
|
||||
|
||||
[registries.alternative]
|
||||
index = '{alt}'
|
||||
|
||||
[registries.alternative2]
|
||||
index = '{alt2}'
|
||||
"#,
|
||||
reg = registry_url(),
|
||||
alt = alt_registry_url(),
|
||||
alt2 = generate_url("alternative2-registry")
|
||||
alt = alt_registry_url()
|
||||
)
|
||||
.as_bytes()
|
||||
));
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! Tests for the `cargo login` command.
|
||||
|
||||
use std::fs::{self, File};
|
||||
use std::fs::{self, File, OpenOptions};
|
||||
use std::io::prelude::*;
|
||||
use std::path::PathBuf;
|
||||
|
||||
@ -8,7 +8,7 @@ use cargo::core::Shell;
|
||||
use cargo::util::config::Config;
|
||||
use cargo_test_support::install::cargo_home;
|
||||
use cargo_test_support::registry::{self, registry_url};
|
||||
use cargo_test_support::{cargo_process, t};
|
||||
use cargo_test_support::{cargo_process, paths, t};
|
||||
use toml;
|
||||
|
||||
const TOKEN: &str = "test-token";
|
||||
@ -170,6 +170,20 @@ fn new_credentials_is_used_instead_old() {
|
||||
#[cargo_test]
|
||||
fn registry_credentials() {
|
||||
registry::init();
|
||||
|
||||
let config = paths::home().join(".cargo/config");
|
||||
let mut f = OpenOptions::new().append(true).open(config).unwrap();
|
||||
t!(f.write_all(
|
||||
format!(
|
||||
r#"
|
||||
[registries.alternative2]
|
||||
index = '{}'
|
||||
"#,
|
||||
registry::generate_url("alternative2-registry")
|
||||
)
|
||||
.as_bytes(),
|
||||
));
|
||||
|
||||
registry::init_alt2_registry();
|
||||
setup_new_credentials();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user