-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Load credentials and add tests for
yank
and owner
commands
- Loading branch information
Showing
5 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
//! Tests for the `cargo owner` command. | ||
|
||
use std::fs::{self, File}; | ||
use std::io::prelude::*; | ||
|
||
use cargo_test_support::project; | ||
use cargo_test_support::registry::{self, api_path, registry_url}; | ||
|
||
fn setup(name: &str) { | ||
fs::create_dir_all(&api_path().join(format!("api/v1/crates/{}", name))).unwrap(); | ||
|
||
let dest = api_path().join(format!("api/v1/crates/{}/owners", name)); | ||
|
||
let content = r#"{ | ||
"users": [ | ||
{ | ||
"id": 70, | ||
"login": "github:rust-lang:core", | ||
"name": "Core" | ||
} | ||
] | ||
}"#; | ||
|
||
File::create(&dest) | ||
.unwrap() | ||
.write_all(content.as_bytes()) | ||
.unwrap(); | ||
} | ||
|
||
#[cargo_test] | ||
fn simple_list() { | ||
registry::init(); | ||
setup("foo"); | ||
|
||
let p = project() | ||
.file( | ||
"Cargo.toml", | ||
r#" | ||
[project] | ||
name = "foo" | ||
version = "0.0.1" | ||
authors = [] | ||
license = "MIT" | ||
description = "foo" | ||
"#, | ||
) | ||
.file("src/main.rs", "fn main() {}") | ||
.build(); | ||
|
||
p.cargo("owner -l --index") | ||
.arg(registry_url().to_string()) | ||
.run(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
//! Tests for the `cargo yank` command. | ||
|
||
use std::fs::{self, File}; | ||
use std::io::prelude::*; | ||
|
||
use cargo_test_support::project; | ||
use cargo_test_support::registry::{self, api_path, registry_url}; | ||
|
||
fn setup(name: &str, version: &str) { | ||
fs::create_dir_all(&api_path().join(format!("api/v1/crates/{}/{}", name, version))).unwrap(); | ||
|
||
let dest = api_path().join(format!("api/v1/crates/{}/{}/yank", name, version)); | ||
|
||
let content = r#"{ | ||
"ok": true | ||
}"#; | ||
|
||
File::create(&dest) | ||
.unwrap() | ||
.write_all(content.as_bytes()) | ||
.unwrap(); | ||
} | ||
|
||
#[cargo_test] | ||
fn simple() { | ||
registry::init(); | ||
setup("foo", "0.0.1"); | ||
|
||
let p = project() | ||
.file( | ||
"Cargo.toml", | ||
r#" | ||
[project] | ||
name = "foo" | ||
version = "0.0.1" | ||
authors = [] | ||
license = "MIT" | ||
description = "foo" | ||
"#, | ||
) | ||
.file("src/main.rs", "fn main() {}") | ||
.build(); | ||
|
||
p.cargo("yank --vers 0.0.1 --index") | ||
.arg(registry_url().to_string()) | ||
.run(); | ||
} |