Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link to sourcegraph #1947

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ pub(crate) struct Blob {
pub(crate) compression: Option<CompressionAlgorithm>,
}

impl Blob {
pub(crate) fn is_empty(&self) -> bool {
self.mime == "application/x-empty"
}
}

fn get_file_list_from_dir<P: AsRef<Path>>(path: P, files: &mut Vec<PathBuf>) -> Result<()> {
let path = path.as_ref();

Expand Down Expand Up @@ -185,26 +179,6 @@ impl Storage {
})
}

pub(crate) fn fetch_source_file(
&self,
name: &str,
version: &str,
path: &str,
archive_storage: bool,
) -> Result<Blob> {
Ok(if archive_storage {
self.get_from_archive(
&source_archive_path(name, version),
path,
self.max_file_size_for(path),
None,
)?
} else {
let remote_path = format!("sources/{}/{}/{}", name, version, path);
self.get(&remote_path, self.max_file_size_for(path))?
})
}

pub(crate) fn rustdoc_file_exists(
&self,
name: &str,
Expand Down
5 changes: 0 additions & 5 deletions src/test/fakes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,6 @@ impl<'a> FakeRelease<'a> {
}
}

pub(crate) fn description(mut self, new: impl Into<String>) -> Self {
self.package.description = Some(new.into());
self
}

pub(crate) fn release_time(mut self, new: DateTime<Utc>) -> Self {
self.registry_release_data.release_time = new;
self
Expand Down
2 changes: 1 addition & 1 deletion src/web/builds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ mod tests {
let body = String::from_utf8(resp.bytes().unwrap().to_vec()).unwrap();
assert!(body.contains("<a href=\"/crate/aquarelle/latest/features\""));
assert!(body.contains("<a href=\"/crate/aquarelle/latest/builds\""));
assert!(body.contains("<a href=\"/crate/aquarelle/latest/source/\""));
assert!(body.contains("<a href=\"https://sourcegraph.com/crates/[email protected]\""));
assert!(body.contains("<a href=\"/crate/aquarelle/latest\""));

let resp_json = env
Expand Down
2 changes: 1 addition & 1 deletion src/web/crate_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ mod tests {
let body = String::from_utf8(resp.bytes().unwrap().to_vec()).unwrap();
assert!(body.contains("<a href=\"/crate/dummy/latest/features\""));
assert!(body.contains("<a href=\"/crate/dummy/latest/builds\""));
assert!(body.contains("<a href=\"/crate/dummy/latest/source/\""));
assert!(body.contains("<a href=\"https://sourcegraph.com/crates/[email protected]\""));
assert!(body.contains("<a href=\"/crate/dummy/latest\""));

assert_redirect("/crate/dummy/latest/", "/crate/dummy/latest", web)?;
Expand Down
2 changes: 1 addition & 1 deletion src/web/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ mod tests {
assert!(resp.url().as_str().ends_with("/crate/foo/latest/features"));
let body = String::from_utf8(resp.bytes().unwrap().to_vec()).unwrap();
assert!(body.contains("<a href=\"/crate/foo/latest/builds\""));
assert!(body.contains("<a href=\"/crate/foo/latest/source/\""));
assert!(body.contains("<a href=\"https://sourcegraph.com/crates/[email protected]\""));
assert!(body.contains("<a href=\"/crate/foo/latest\""));
Ok(())
});
Expand Down
45 changes: 0 additions & 45 deletions src/web/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -853,32 +853,6 @@ mod test {
});
}

#[test]
fn test_show_clipboard_for_crate_pages() {
wrapper(|env| {
env.fake_release()
.name("fake_crate")
.version("0.0.1")
.source_file("test.rs", &[])
.create()
.unwrap();
let web = env.frontend();
assert!(clipboard_is_present_for_path(
"/crate/fake_crate/0.0.1",
web
));
assert!(clipboard_is_present_for_path(
"/crate/fake_crate/0.0.1/source/",
web
));
assert!(clipboard_is_present_for_path(
"/fake_crate/0.0.1/fake_crate",
web
));
Ok(())
});
}

#[test]
fn test_hide_clipboard_for_non_crate_pages() {
wrapper(|env| {
Expand Down Expand Up @@ -968,25 +942,6 @@ mod test {
})
}

#[test]
fn can_view_source() {
wrapper(|env| {
env.fake_release()
.name("regex")
.version("0.3.0")
.source_file("src/main.rs", br#"println!("definitely valid rust")"#)
.create()
.unwrap();

let web = env.frontend();
assert_success("/crate/regex/0.3.0/source/src/main.rs", web)?;
assert_success("/crate/regex/0.3.0/source", web)?;
assert_success("/crate/regex/0.3.0/source/src", web)?;
assert_success("/regex/0.3.0/src/regex/main.rs.html", web)?;
Ok(())
})
}

#[test]
// https://github.com/rust-lang/docs.rs/issues/223
fn prereleases_are_not_considered_for_semver() {
Expand Down
Loading