cargo_test_support

Module publish

Source
Expand description

Helpers for testing cargo package / cargo publish

ยงExample

// This replaces `registry::init()` and must be called before `Package::new().publish()`
let registry = RegistryBuilder::new().http_api().http_index().build();

let p = project()
    .file(
        "Cargo.toml",
        r#"
            [package]
            name = "foo"
            version = "0.0.1"
            edition = "2015"
            authors = []
            license = "MIT"
            description = "foo"
        "#,
    )
    .file("src/main.rs", "fn main() {}")
    .build();

p.cargo("publish --no-verify")
    .replace_crates_io(registry.index_url())
    .run();

validate_upload(
    r#"
    {
      "authors": [],
      "badges": {},
      "categories": [],
      "deps": [],
      "description": "foo",
      "documentation": null,
      "features": {},
      "homepage": null,
      "keywords": [],
      "license": "MIT",
      "license_file": null,
      "links": null,
      "name": "foo",
      "readme": null,
      "readme_file": null,
      "repository": null,
      "rust_version": null,
      "vers": "0.0.1"
      }
    "#,
    "foo-0.0.1.crate",
    &["Cargo.lock", "Cargo.toml", "Cargo.toml.orig", "src/main.rs"],
);

Functionsยง