Skip to content

Commit 6793f4a

Browse files
committed
Move categories::sync functionality under a new boot module
1 parent ffc9af3 commit 6793f4a

File tree

6 files changed

+10
-8
lines changed

6 files changed

+10
-8
lines changed

src/bin/server.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ fn main() {
5050

5151
// On every server restart, ensure the categories available in the database match
5252
// the information in *src/categories.toml*.
53-
let categories_toml = include_str!("../categories.toml");
54-
cargo_registry::categories::sync(&categories_toml).unwrap();
53+
let categories_toml = include_str!("../boot/categories.toml");
54+
cargo_registry::boot::categories::sync(&categories_toml).unwrap();
5555

5656
let heroku = env::var("HEROKU").is_ok();
5757
let port = if heroku {
File renamed without changes.
File renamed without changes.

src/boot/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod categories;

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ use util::{R404, C, R};
7575

7676
pub mod app;
7777
pub mod badge;
78-
pub mod categories;
78+
pub mod boot;
7979
pub mod category;
8080
pub mod config;
8181
pub mod crate_owner_invitation;

src/tests/categories.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ fn select_slugs(conn: &PgConnection) -> Vec<String> {
6060
fn sync_adds_new_categories() {
6161
let conn = pg_connection();
6262

63-
::cargo_registry::categories::sync_with_connection(ALGORITHMS_AND_SUCH, &conn).unwrap();
63+
::cargo_registry::boot::categories::sync_with_connection(ALGORITHMS_AND_SUCH, &conn).unwrap();
6464

6565
let categories = select_slugs(&conn);
6666
assert_eq!(categories, vec!["algorithms", "algorithms::such"]);
@@ -70,8 +70,8 @@ fn sync_adds_new_categories() {
7070
fn sync_removes_missing_categories() {
7171
let conn = pg_connection();
7272

73-
::cargo_registry::categories::sync_with_connection(ALGORITHMS_AND_SUCH, &conn).unwrap();
74-
::cargo_registry::categories::sync_with_connection(ALGORITHMS, &conn).unwrap();
73+
::cargo_registry::boot::categories::sync_with_connection(ALGORITHMS_AND_SUCH, &conn).unwrap();
74+
::cargo_registry::boot::categories::sync_with_connection(ALGORITHMS, &conn).unwrap();
7575

7676
let categories = select_slugs(&conn);
7777
assert_eq!(categories, vec!["algorithms"]);
@@ -81,8 +81,9 @@ fn sync_removes_missing_categories() {
8181
fn sync_adds_and_removes() {
8282
let conn = pg_connection();
8383

84-
::cargo_registry::categories::sync_with_connection(ALGORITHMS_AND_SUCH, &conn).unwrap();
85-
::cargo_registry::categories::sync_with_connection(ALGORITHMS_AND_ANOTHER, &conn).unwrap();
84+
::cargo_registry::boot::categories::sync_with_connection(ALGORITHMS_AND_SUCH, &conn).unwrap();
85+
::cargo_registry::boot::categories::sync_with_connection(ALGORITHMS_AND_ANOTHER, &conn)
86+
.unwrap();
8687

8788
let categories = select_slugs(&conn);
8889
assert_eq!(categories, vec!["algorithms", "another"]);

0 commit comments

Comments
 (0)