Skip to content

Fix the krate::downloads test #1545

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

Merged
merged 1 commit into from
Oct 30, 2018
Merged

Conversation

sgrif
Copy link
Contributor

@sgrif sgrif commented Oct 30, 2018

This test wasn't technically wrong, it was just very confusing. The
assert_dl_count function was testing the length of the array returned
by the downloads endpoint. When we test that case insensitivity works,
this makes it look like there's a bug, since we'd intuitively expect
assert_dl_count expect 2 downloads. But it wasn't testing the number
of downloads, it was testing the number of records we returned (one
record per version per day that there were downloads). So the JSON we
returned was correct:

[
  {
    "version_id": 1,
    "date": "2018-10-30",
    "downloads": 2,
  }
]

But the test didn't really reflect what we expected. This changes it to
actually test the sum of the "downloads" field, which is intuitively
what you'd expect this to be testing.

@sgrif sgrif requested a review from jtgeibel October 30, 2018 21:35
This test wasn't technically wrong, it was just very confusing. The
`assert_dl_count` function was testing the length of the array returned
by the downloads endpoint. When we test that case insensitivity works,
this makes it look like there's a bug, since we'd intuitively expect
`assert_dl_count` expect 2 downloads. But it wasn't testing the number
of downloads, it was testing the number of records we returned (one
record per version per day that there were downloads). So the JSON we
returned was correct:

    [
      {
        "version_id": 1,
        "date": "2018-10-30",
        "downloads": 2,
      }
    ]

But the test didn't really reflect what we expected. This changes it to
actually test the sum of the "downloads" field, which is intuitively
what you'd expect this to be testing.
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.

Yay for bugs that only live in test code. Thanks for tracking this down.

bors: r+

bors-voyager bot added a commit that referenced this pull request Oct 30, 2018
1545: Fix the `krate::downloads` test r=jtgeibel a=sgrif

This test wasn't technically wrong, it was just very confusing. The
`assert_dl_count` function was testing the length of the array returned
by the downloads endpoint. When we test that case insensitivity works,
this makes it look like there's a bug, since we'd intuitively expect
`assert_dl_count` expect 2 downloads. But it wasn't testing the number
of downloads, it was testing the number of records we returned (one
record per version per day that there were downloads). So the JSON we
returned was correct:

    [
      {
        "version_id": 1,
        "date": "2018-10-30",
        "downloads": 2,
      }
    ]

But the test didn't really reflect what we expected. This changes it to
actually test the sum of the "downloads" field, which is intuitively
what you'd expect this to be testing.

Co-authored-by: Sean Griffin <[email protected]>
@bors-voyager
Copy link
Contributor

bors-voyager bot commented Oct 30, 2018

Build succeeded

@bors-voyager bors-voyager bot merged commit e97908e into rust-lang:master Oct 30, 2018
@sgrif sgrif deleted the sg-fix-test branch March 9, 2019 01:33
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