File tree Expand file tree Collapse file tree 3 files changed +16
-31
lines changed Expand file tree Collapse file tree 3 files changed +16
-31
lines changed Original file line number Diff line number Diff line change 1
1
//! Tests for the `cargo owner` command.
2
2
3
- use std:: fs:: { self , File } ;
4
- use std:: io:: prelude:: * ;
3
+ use std:: fs;
5
4
5
+ use cargo_test_support:: paths:: CargoPathExt ;
6
6
use cargo_test_support:: project;
7
7
use cargo_test_support:: registry:: { self , api_path, registry_url} ;
8
8
9
9
fn setup ( name : & str ) {
10
- fs :: create_dir_all ( & api_path ( ) . join ( format ! ( "api/v1/crates/{}" , name) ) ) . unwrap ( ) ;
11
-
12
- let dest = api_path ( ) . join ( format ! ( "api/v1/crates/{}/owners" , name ) ) ;
13
-
14
- let content = r#"{
10
+ let dir = api_path ( ) . join ( format ! ( "api/v1/crates/{}" , name) ) ;
11
+ dir . mkdir_p ( ) ;
12
+ fs :: write (
13
+ dir . join ( "owners" ) ,
14
+ r#"{
15
15
"users": [
16
16
{
17
17
"id": 70,
18
18
"login": "github:rust-lang:core",
19
19
"name": "Core"
20
20
}
21
21
]
22
- }"# ;
23
-
24
- File :: create ( & dest)
25
- . unwrap ( )
26
- . write_all ( content. as_bytes ( ) )
27
- . unwrap ( ) ;
22
+ }"# ,
23
+ )
24
+ . unwrap ( ) ;
28
25
}
29
26
30
27
#[ cargo_test]
Original file line number Diff line number Diff line change @@ -1267,10 +1267,7 @@ fn credentials_ambiguous_filename() {
1267
1267
registry:: init ( ) ;
1268
1268
1269
1269
let credentials_toml = paths:: home ( ) . join ( ".cargo/credentials.toml" ) ;
1270
- File :: create ( & credentials_toml)
1271
- . unwrap ( )
1272
- . write_all ( br#"token = "api-token""# )
1273
- . unwrap ( ) ;
1270
+ fs:: write ( credentials_toml, r#"token = "api-token""# ) . unwrap ( ) ;
1274
1271
1275
1272
let p = project ( )
1276
1273
. file (
Original file line number Diff line number Diff line change 1
1
//! Tests for the `cargo yank` command.
2
2
3
- use std:: fs:: { self , File } ;
4
- use std:: io:: prelude:: * ;
3
+ use std:: fs;
5
4
5
+ use cargo_test_support:: paths:: CargoPathExt ;
6
6
use cargo_test_support:: project;
7
7
use cargo_test_support:: registry:: { self , api_path, registry_url} ;
8
8
9
9
fn setup ( name : & str , version : & str ) {
10
- fs:: create_dir_all ( & api_path ( ) . join ( format ! ( "api/v1/crates/{}/{}" , name, version) ) ) . unwrap ( ) ;
11
-
12
- let dest = api_path ( ) . join ( format ! ( "api/v1/crates/{}/{}/yank" , name, version) ) ;
13
-
14
- let content = r#"{
15
- "ok": true
16
- }"# ;
17
-
18
- File :: create ( & dest)
19
- . unwrap ( )
20
- . write_all ( content. as_bytes ( ) )
21
- . unwrap ( ) ;
10
+ let dir = api_path ( ) . join ( format ! ( "api/v1/crates/{}/{}" , name, version) ) ;
11
+ dir. mkdir_p ( ) ;
12
+ fs:: write ( dir. join ( "yank" ) , r#"{"ok": true}"# ) . unwrap ( ) ;
22
13
}
23
14
24
15
#[ cargo_test]
You can’t perform that action at this time.
0 commit comments