Skip to content

Commit bcbde30

Browse files
committed
Fix I'm feeling lucky test to be more reliable
After digging into 44f98be I discovered the reason of the problems I had with this test-case.
1 parent cb78679 commit bcbde30

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl Config {
9393
max_parse_memory: env("DOCSRS_MAX_PARSE_MEMORY", 5 * 1024 * 1024)?,
9494
registry_gc_interval: env("DOCSRS_REGISTRY_GC_INTERVAL", 60 * 60)?,
9595

96-
random_crate_search_view_size: env("DOCSRS_RANDOM_CRATE_SEARCH_VIEW_SIZE", 50000)?,
96+
random_crate_search_view_size: env("DOCSRS_RANDOM_CRATE_SEARCH_VIEW_SIZE", 500)?,
9797

9898
rustwide_workspace: env("CRATESFYI_RUSTWIDE_WORKSPACE", PathBuf::from(".workspace"))?,
9999
inside_docker: env("DOCS_RS_DOCKER", false)?,

src/web/releases.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ fn redirect_to_random_crate(req: &Request, conn: &mut PoolClient) -> IronResult<
529529
releases.rustdoc_status = TRUE AND
530530
github_repos.stars >= 100
531531
LIMIT 1",
532-
&[&(config.random_crate_search_view_size as i32),]
532+
&[&(config.random_crate_search_view_size as i32)]
533533
)
534534
);
535535

@@ -1089,6 +1089,18 @@ mod tests {
10891089
#[test]
10901090
fn im_feeling_lucky_with_stars() {
10911091
wrapper(|env| {
1092+
{
1093+
// The normal test-setup will offset all primary sequences by 10k
1094+
// to prevent errors with foreign key relations.
1095+
// Random-crate-search relies on the sequence for the crates-table
1096+
// to find a maximum possible ID. This combined with only one actual
1097+
// crate in the db breaks this test.
1098+
// That's why we reset the id-sequence to zero for this test.
1099+
1100+
let mut conn = env.db().conn();
1101+
conn.execute(r#"ALTER SEQUENCE crates_id_seq RESTART WITH 1"#, &[])?;
1102+
}
1103+
10921104
let web = env.frontend();
10931105
env.fake_release()
10941106
.github_stats("some/repo", 333, 22, 11)

0 commit comments

Comments
 (0)