Skip to content

Commit 5537e70

Browse files
committed
tests/builders/publish: Extract generate_empty_tarball() function
1 parent 3e5f0b4 commit 5537e70

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/tests/builders/publish.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@ lazy_static! {
99
// The bytes of an empty tarball is not an empty vector of bytes because of tarball headers.
1010
// Unless files are added to a PublishBuilder, the `.crate` tarball that gets uploaded
1111
// will be empty, so precompute the empty tarball bytes to use as a default.
12-
static ref EMPTY_TARBALL_BYTES: Vec<u8> = {
13-
let mut empty_tarball = vec![];
14-
{
15-
let mut ar =
16-
tar::Builder::new(GzEncoder::new(&mut empty_tarball, Compression::default()));
17-
assert_ok!(ar.finish());
18-
}
19-
empty_tarball
20-
};
12+
static ref EMPTY_TARBALL_BYTES: Vec<u8> = generate_empty_tarball();
13+
}
14+
15+
fn generate_empty_tarball() -> Vec<u8> {
16+
let mut empty_tarball = vec![];
17+
{
18+
let mut ar = tar::Builder::new(GzEncoder::new(&mut empty_tarball, Compression::default()));
19+
assert_ok!(ar.finish());
20+
}
21+
empty_tarball
2122
}
2223

2324
/// A builder for constructing a crate for the purposes of testing publishing. If you only need

0 commit comments

Comments
 (0)