Skip to content

Commit 9711273

Browse files
committed
StorageConfig: Extract in_memory() fn
1 parent 30bef3c commit 9711273

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/storage.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ pub struct S3Config {
5050
}
5151

5252
impl StorageConfig {
53+
pub fn in_memory() -> Self {
54+
Self::InMemory
55+
}
56+
5357
pub fn from_environment() -> Self {
5458
if let Ok(bucket) = dotenvy::var("S3_BUCKET") {
5559
let region = dotenvy::var("S3_REGION").ok();
@@ -339,7 +343,7 @@ mod tests {
339343
use tempfile::NamedTempFile;
340344

341345
pub async fn prepare() -> Storage {
342-
let storage = Storage::from_config(&StorageConfig::InMemory);
346+
let storage = Storage::from_config(&StorageConfig::in_memory());
343347

344348
let files_to_create = vec![
345349
"crates/bar/bar-2.0.0.crate",
@@ -367,7 +371,7 @@ mod tests {
367371

368372
#[test]
369373
fn locations() {
370-
let storage = Storage::from_config(&StorageConfig::InMemory);
374+
let storage = Storage::from_config(&StorageConfig::in_memory());
371375

372376
let crate_tests = vec![
373377
("foo", "1.2.3", "/crates/foo/foo-1.2.3.crate"),
@@ -458,7 +462,7 @@ mod tests {
458462

459463
#[tokio::test]
460464
async fn upload_crate_file() {
461-
let s = Storage::from_config(&StorageConfig::InMemory);
465+
let s = Storage::from_config(&StorageConfig::in_memory());
462466

463467
s.upload_crate_file("foo", "1.2.3", Bytes::new())
464468
.await
@@ -480,7 +484,7 @@ mod tests {
480484

481485
#[tokio::test]
482486
async fn upload_readme() {
483-
let s = Storage::from_config(&StorageConfig::InMemory);
487+
let s = Storage::from_config(&StorageConfig::in_memory());
484488

485489
let bytes = Bytes::from_static(b"hello world");
486490
s.upload_readme("foo", "1.2.3", bytes.clone())
@@ -501,7 +505,7 @@ mod tests {
501505

502506
#[tokio::test]
503507
async fn sync_index() {
504-
let s = Storage::from_config(&StorageConfig::InMemory);
508+
let s = Storage::from_config(&StorageConfig::in_memory());
505509

506510
assert!(stored_files(&s.store).await.is_empty());
507511

@@ -518,7 +522,7 @@ mod tests {
518522

519523
#[tokio::test]
520524
async fn upload_db_dump() {
521-
let s = Storage::from_config(&StorageConfig::InMemory);
525+
let s = Storage::from_config(&StorageConfig::in_memory());
522526

523527
assert!(stored_files(&s.store).await.is_empty());
524528

src/tests/util/test_app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ fn simple_config() -> config::Server {
387387
max_blocking_threads: None,
388388
use_nginx_wrapper: false,
389389
db,
390-
storage: StorageConfig::InMemory,
390+
storage: StorageConfig::in_memory(),
391391
session_key: cookie::Key::derive_from("test this has to be over 32 bytes long".as_bytes()),
392392
gh_client_id: ClientId::new(dotenvy::var("GH_CLIENT_ID").unwrap_or_default()),
393393
gh_client_secret: ClientSecret::new(dotenvy::var("GH_CLIENT_SECRET").unwrap_or_default()),

0 commit comments

Comments
 (0)