Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Add a test for trying to open a crate that has not yet been downloaded #5

Open
carols10cents opened this issue Oct 4, 2015 · 1 comment

Comments

@carols10cents
Copy link
Owner

In main.rs, add a unit test for the cargo_dir function that checks that it panics if we have specified a new crate in the Cargo.toml file but have not yet run any command that would fetch that crate's source to our local filesystem.

Use the existing test marked should_panic for an example of how to make a test check that a function panics.

As I write this up, I'm seeing that it would be easier if a function to read the Cargo.toml contents was extracted from the cargo_dir function and, instead, cargo_dir took the contents of Cargo.toml as an argument. That would make it easier to pass different Cargo.toml contents in for a unit test, so that should be part of this issue and should be done before adding the test.

I'd accept a PR that adds this test even if it fails, or if it fails with a weird error message! I'm not sure if I've coded things in such a way as to reuse existing cargo knowledge or not. Eventually I'd like this to panic with a message like "This crate has not been fetched yet; please run cargo install" first.

Bonus points if you change the code to make the test pass!

@carols10cents carols10cents changed the title Add tests for trying to open a crate that has not yet been downloaded Add a test for trying to open a crate that has not yet been downloaded Oct 4, 2015
@marti1125
Copy link
Contributor

count with me 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants