Skip to content

Commit 8fad200

Browse files
Nemo157Joshua Nelson
authored andcommitted
Add test for latest version platform specific redirect with search
1 parent 3ae6893 commit 8fad200

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/test/fakes.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,11 @@ impl<'a> FakeRelease<'a> {
118118
}
119119

120120
pub(crate) fn add_platform<S: Into<String>>(mut self, platform: S) -> Self {
121+
let platform = platform.into();
121122
let name = self.package.targets[0].name.clone();
122-
let target = Target::dummy_lib(name, Some(platform.into()));
123+
let target = Target::dummy_lib(name, Some(platform.clone()));
123124
self.package.targets.push(target);
125+
self.doc_targets.push(platform);
124126
self
125127
}
126128

src/test/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ pub(crate) struct TestEnvironment {
9393

9494
impl TestEnvironment {
9595
fn new() -> Self {
96+
// If this fails it's probably already initialized
97+
let _ = env_logger::try_init();
9698
Self {
9799
db: OnceCell::new(),
98100
frontend: OnceCell::new(),

src/web/rustdoc.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,7 @@ mod test {
675675
.name("dummy")
676676
.version("0.1.0")
677677
.add_platform("x86_64-pc-windows-msvc")
678+
.rustdoc_file("dummy/struct.Blah.html", b"lah")
678679
.create()
679680
.unwrap();
680681
db.fake_release()
@@ -700,9 +701,22 @@ mod test {
700701
"/dummy/0.2.0/x86_64-pc-windows-msvc/dummy/index.html"
701702
);
702703

704+
// With deleted file platform specific redirect also handles search
705+
let redirect = latest_version_redirect(
706+
"/dummy/0.1.0/x86_64-pc-windows-msvc/dummy/struct.Blah.html",
707+
web,
708+
)?;
709+
assert_eq!(redirect, "/dummy/0.2.0/x86_64-pc-windows-msvc?search=Blah");
710+
assert_redirect(
711+
&redirect,
712+
"/dummy/0.2.0/x86_64-pc-windows-msvc/dummy/?search=Blah",
713+
web,
714+
)?;
715+
703716
Ok(())
704717
})
705718
}
719+
706720
#[test]
707721
fn redirect_latest_goes_to_crate_if_build_failed() {
708722
wrapper(|env| {

0 commit comments

Comments
 (0)