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

Test improvements, conversions to using the new API #1546

Merged
merged 17 commits into from
Nov 3, 2018

Conversation

carols10cents
Copy link
Member

More!

tests/all.rs is big enough. Also add documentation.
This test, which logs in, logs out, then tries to publish a crate with
an invalid token, isn't actually testing useful logic because the cookie
logic for the tests is injected into the test app. Actual browser cookie
logic isn't exercised in these tests; at best, this test is testing the
tests.

The other parts of this test function are fine.
Add a method to add a dependency on PublishBuilder
Renaming to better describe what's being tested. Added another method to
PublishBuilder for adding a renamed dependency.
This gets rid of the renamed_dependency method on PublishBuilder because
that should be the responsibility of the DependencyBuilder.
Copy link
Member

@jtgeibel jtgeibel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Just a few minor comments below.

let mut req = new_req(name, "1.0.0");
sign_in(&mut req, &app);
let json = bad_resp!(middle.call(&mut req));
let (_, _, _, token) = TestApp::with_proxy().with_token();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can get away with TestApp::init() here because the crates aren't actually published.

@@ -694,27 +679,17 @@ fn new_renamed_crate() {

#[test]
fn new_krate_non_canon_crate_name_dependencies() {
let (_b, app, middle) = app();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test name sounds like this should create foo-dep and then attempt to publish a crate depending on foo_dep, which I think would be expected to fail. You've ported the existing test faithfully, but currently this seems identical to the first half of test new_krate_with_dependency. Feel free to just throw a comment in for now if you agree.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree this test name is confusing and it took me a minute to figure out why it was doing what it was doing as well. The reason is we had a bug where you couldn't publish crates that depended on crates where their name didn't equal their canon_crate_name normalized in the database :(

I agree it's largely a duplicate with new_krate_with_dependency, I'm going to delete that test and leave this one with a comment that the dependency name is important :)

@@ -636,9 +638,11 @@ fn new_with_renamed_dependency() {
CrateBuilder::new("package-name", user.as_model().id).expect_build(&conn);
});

let dependency = DependencyBuilder::new("package-name").rename("my-name");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So much clearer 🎉

CrateBuilder::new("foo_wild", user.id).expect_build(&conn);
}
let json = bad_resp!(middle.call(&mut req));
let (app, _, user, token) = TestApp::with_proxy().with_token();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be TestApp::init() as well.

let conn = app.diesel_database.get().unwrap();
let user = new_user("foo").create_or_update(&conn).unwrap();
sign_in_as(&mut req, &user);
let (app, _, user, token) = TestApp::with_proxy().with_token();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TestApp::init()

This tests the same functionality as the
new_krate_non_canon_crate_name_dependencies test, but that test has
an additional detail that tests for a specific regression so we'll keep
that one.
This makes the name less confusing but still ensures we have a
regression test for the specific bug mentioned.
@carols10cents
Copy link
Member Author

Ready for rereview @jtgeibel ! Thank you!

@jtgeibel
Copy link
Member

jtgeibel commented Nov 3, 2018

LGTM! Thanks for adding the link in the test to the original issue.

bors: r+

bors-voyager bot added a commit that referenced this pull request Nov 3, 2018
1546: Test improvements, conversions to using the new API r=jtgeibel a=carols10cents

More!

Co-authored-by: Carol (Nichols || Goulding) <carol.nichols@gmail.com>
@bors-voyager
Copy link
Contributor

bors-voyager bot commented Nov 3, 2018

Build succeeded

@bors-voyager bors-voyager bot merged commit e7b52bb into rust-lang:master Nov 3, 2018
@carols10cents carols10cents deleted the cant-stop-wont-stop branch November 5, 2018 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants