Skip to content

Commit 5c70708

Browse files
authored
EncodableCrateUpload: Remove obsolete badges field (#5431)
1 parent acf64c8 commit 5c70708

File tree

3 files changed

+3
-64
lines changed

3 files changed

+3
-64
lines changed

src/tests/builders/publish.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use cargo_registry::views::krate_publish as u;
2-
use std::{collections::BTreeMap, collections::HashMap, io::Read};
2+
use std::{collections::BTreeMap, io::Read};
33

44
use flate2::{write::GzEncoder, Compression};
55
use once_cell::sync::Lazy;
@@ -24,7 +24,6 @@ fn generate_empty_tarball() -> Vec<u8> {
2424
/// a crate to exist and don't need to test behavior caused by the publish request, inserting
2525
/// a crate into the database directly by using CrateBuilder will be faster.
2626
pub struct PublishBuilder {
27-
badges: HashMap<String, HashMap<String, String>>,
2827
categories: Vec<String>,
2928
deps: Vec<u::EncodableCrateDependency>,
3029
desc: Option<String>,
@@ -44,7 +43,6 @@ impl PublishBuilder {
4443
/// in its tarball.
4544
pub fn new(krate_name: &str) -> Self {
4645
PublishBuilder {
47-
badges: HashMap::new(),
4846
categories: vec![],
4947
deps: vec![],
5048
desc: Some("description".to_string()),
@@ -150,12 +148,6 @@ impl PublishBuilder {
150148
self
151149
}
152150

153-
/// Add badges to this crate.
154-
pub fn badges(mut self, badges: HashMap<String, HashMap<String, String>>) -> Self {
155-
self.badges = badges;
156-
self
157-
}
158-
159151
/// Remove the license from this crate. Publish will fail unless license or license file is set.
160152
pub fn unset_license(mut self) -> Self {
161153
self.license = None;
@@ -202,7 +194,6 @@ impl PublishBuilder {
202194
license: self.license,
203195
license_file: self.license_file,
204196
repository: None,
205-
badges: Some(self.badges),
206197
links: None,
207198
};
208199

src/tests/krate/publish.rs

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use diesel::{delete, update, ExpressionMethods, QueryDsl, RunQueryDsl};
1111
use flate2::write::GzEncoder;
1212
use flate2::Compression;
1313
use http::StatusCode;
14-
use std::collections::{BTreeMap, HashMap};
14+
use std::collections::BTreeMap;
1515
use std::io::Read;
1616
use std::iter::FromIterator;
1717
use std::time::Duration;
@@ -781,57 +781,6 @@ fn ignored_categories() {
781781
assert_eq!(json.warnings.invalid_categories, vec!["bar"]);
782782
}
783783

784-
#[test]
785-
fn good_badges() {
786-
let (_, anon, _, token) = TestApp::full().with_token();
787-
788-
let mut badges = HashMap::new();
789-
let mut badge_attributes = HashMap::new();
790-
badge_attributes.insert(
791-
String::from("repository"),
792-
String::from("rust-lang/crates.io"),
793-
);
794-
badges.insert(String::from("travis-ci"), badge_attributes);
795-
796-
let crate_to_publish = PublishBuilder::new("foobadger").badges(badges);
797-
798-
let json = token.publish_crate(crate_to_publish).good();
799-
assert_eq!(json.krate.name, "foobadger");
800-
assert_eq!(json.krate.max_version, "1.0.0");
801-
802-
let json = anon.show_crate("foobadger");
803-
let badges = json.krate.badges.unwrap();
804-
assert_eq!(badges.len(), 0);
805-
}
806-
807-
#[test]
808-
fn ignored_badges() {
809-
let (_, anon, _, token) = TestApp::full().with_token();
810-
811-
let mut badges = HashMap::new();
812-
813-
// Known badge type, missing required repository attribute
814-
let mut badge_attributes = HashMap::new();
815-
badge_attributes.insert(String::from("branch"), String::from("master"));
816-
badges.insert(String::from("travis-ci"), badge_attributes);
817-
818-
// Unknown badge type
819-
let mut unknown_badge_attributes = HashMap::new();
820-
unknown_badge_attributes.insert(String::from("repository"), String::from("rust-lang/rust"));
821-
badges.insert(String::from("not-a-badge"), unknown_badge_attributes);
822-
823-
let crate_to_publish = PublishBuilder::new("foo_ignored_badge").badges(badges);
824-
825-
let json = token.publish_crate(crate_to_publish).good();
826-
assert_eq!(json.krate.name, "foo_ignored_badge");
827-
assert_eq!(json.krate.max_version, "1.0.0");
828-
assert_eq!(json.warnings.invalid_badges.len(), 0);
829-
830-
let json = anon.show_crate("foo_ignored_badge");
831-
let badges = json.krate.badges.unwrap();
832-
assert_eq!(badges.len(), 0);
833-
}
834-
835784
#[test]
836785
fn license_and_description_required() {
837786
let (_, _, _, token) = TestApp::full().with_token();

src/views/krate_publish.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//! and manages the serialising and deserialising of this information
33
//! to and from structs. The serlializing is only utilised in
44
//! integration tests.
5-
use std::collections::{BTreeMap, HashMap};
5+
use std::collections::BTreeMap;
66

77
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
88

@@ -30,7 +30,6 @@ pub struct EncodableCrateUpload {
3030
pub license: Option<String>,
3131
pub license_file: Option<String>,
3232
pub repository: Option<String>,
33-
pub badges: Option<HashMap<String, HashMap<String, String>>>,
3433
#[serde(default)]
3534
pub links: Option<String>,
3635
}

0 commit comments

Comments
 (0)