]> git.proxmox.com Git - cargo.git/commitdiff
Append `registries` to config
authorTakayuki Nakata <f.seasons017@gmail.com>
Tue, 17 Dec 2019 00:59:45 +0000 (09:59 +0900)
committerTakayuki Nakata <f.seasons017@gmail.com>
Tue, 17 Dec 2019 00:59:45 +0000 (09:59 +0900)
crates/cargo-test-support/src/registry.rs
tests/testsuite/login.rs

index 47b930447bb05abba8d8c7e7df7655f686124718..09d6414acae4e1b722d2baeb7a11a559e1e3cf76 100644 (file)
@@ -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()
     ));
index cb609feaf9d61584dcb5a71a4ad508c3df56a582..86c0c56c6b4900c948265108a1a64c889a456c2b 100644 (file)
@@ -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();