Skip to content

Commit 9e2eb93

Browse files
committed
TestApp: Change crates_from_index_head() to take crate name instead of raw path
1 parent 185df94 commit 9e2eb93

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/tests/krate/publish.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ fn new_with_renamed_dependency() {
161161
token.enqueue_publish(crate_to_publish).good();
162162
app.run_pending_background_jobs();
163163

164-
let crates = app.crates_from_index_head("ne/w-/new-krate");
164+
let crates = app.crates_from_index_head("new-krate");
165165
assert_eq!(crates.len(), 1);
166166
assert_eq!(crates[0].name, "new-krate");
167167
assert_eq!(crates[0].vers, "1.0.0");
@@ -187,7 +187,7 @@ fn new_with_underscore_renamed_dependency() {
187187
token.enqueue_publish(crate_to_publish).good();
188188
app.run_pending_background_jobs();
189189

190-
let crates = app.crates_from_index_head("ne/w-/new-krate");
190+
let crates = app.crates_from_index_head("new-krate");
191191
assert_eq!(crates.len(), 1);
192192
assert_eq!(crates[0].name, "new-krate");
193193
assert_eq!(crates[0].vers, "1.0.0");
@@ -528,7 +528,7 @@ fn new_krate_git_upload() {
528528
token.enqueue_publish(crate_to_publish).good();
529529
app.run_pending_background_jobs();
530530

531-
let crates = app.crates_from_index_head("3/f/fgt");
531+
let crates = app.crates_from_index_head("fgt");
532532
assert_eq!(crates.len(), 1);
533533
assert_eq!(crates[0].name, "fgt");
534534
assert_eq!(crates[0].vers, "1.0.0");
@@ -549,7 +549,7 @@ fn new_krate_git_upload_appends() {
549549
token.enqueue_publish(crate_to_publish).good();
550550
app.run_pending_background_jobs();
551551

552-
let crates = app.crates_from_index_head("3/f/fpp");
552+
let crates = app.crates_from_index_head("fpp");
553553
assert!(crates.len() == 2);
554554
assert_eq!(crates[0].name, "FPP");
555555
assert_eq!(crates[0].vers, "0.0.1");

src/tests/krate/yanking.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ fn yank_works_as_intended() {
4949
token.enqueue_publish(crate_to_publish).good();
5050
app.run_pending_background_jobs();
5151

52-
let crates = app.crates_from_index_head("3/f/fyk");
52+
let crates = app.crates_from_index_head("fyk");
5353
assert_eq!(crates.len(), 1);
5454
assert_some_eq!(crates[0].yanked, false);
5555

@@ -60,7 +60,7 @@ fn yank_works_as_intended() {
6060
// yank it
6161
token.yank("fyk", "1.0.0").good();
6262

63-
let crates = app.crates_from_index_head("3/f/fyk");
63+
let crates = app.crates_from_index_head("fyk");
6464
assert_eq!(crates.len(), 1);
6565
assert_some_eq!(crates[0].yanked, true);
6666

@@ -70,7 +70,7 @@ fn yank_works_as_intended() {
7070
// un-yank it
7171
token.unyank("fyk", "1.0.0").good();
7272

73-
let crates = app.crates_from_index_head("3/f/fyk");
73+
let crates = app.crates_from_index_head("fyk");
7474
assert_eq!(crates.len(), 1);
7575
assert_some_eq!(crates[0].yanked, false);
7676

@@ -80,7 +80,7 @@ fn yank_works_as_intended() {
8080
// yank it
8181
cookie.yank("fyk", "1.0.0").good();
8282

83-
let crates = app.crates_from_index_head("3/f/fyk");
83+
let crates = app.crates_from_index_head("fyk");
8484
assert_eq!(crates.len(), 1);
8585
assert_some_eq!(crates[0].yanked, true);
8686

@@ -90,7 +90,7 @@ fn yank_works_as_intended() {
9090
// un-yank it
9191
cookie.unyank("fyk", "1.0.0").good();
9292

93-
let crates = app.crates_from_index_head("3/f/fyk");
93+
let crates = app.crates_from_index_head("fyk");
9494
assert_eq!(crates.len(), 1);
9595
assert_some_eq!(crates[0].yanked, false);
9696

src/tests/util/test_app.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use cargo_registry::{
1010
};
1111
use std::{rc::Rc, sync::Arc, time::Duration};
1212

13-
use cargo_registry::git::Repository as WorkerRepository;
13+
use cargo_registry::git::{Repository as WorkerRepository, Repository};
1414
use diesel::PgConnection;
1515
use git2::Repository as UpstreamRepository;
1616
use reqwest::{blocking::Client, Proxy};
@@ -134,12 +134,12 @@ impl TestApp {
134134
}
135135

136136
/// Obtain a list of crates from the index HEAD
137-
pub fn crates_from_index_head(&self, path: &str) -> Vec<cargo_registry::git::Crate> {
138-
let path = std::path::Path::new(path);
137+
pub fn crates_from_index_head(&self, crate_name: &str) -> Vec<cargo_registry::git::Crate> {
138+
let path = Repository::relative_index_file(crate_name);
139139
let index = self.upstream_repository();
140140
let tree = index.head().unwrap().peel_to_tree().unwrap();
141141
let blob = tree
142-
.get_path(path)
142+
.get_path(&path)
143143
.unwrap()
144144
.to_object(index)
145145
.unwrap()

0 commit comments

Comments
 (0)