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

Replace foldLeft with traverse in Decoders #101

Merged
merged 3 commits into from
Apr 28, 2017
Merged

Conversation

peterneyens
Copy link
Contributor

No description provided.

@codecov-io
Copy link

codecov-io commented Apr 25, 2017

Codecov Report

Merging #101 into master will increase coverage by 0.32%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #101      +/-   ##
==========================================
+ Coverage   87.81%   88.14%   +0.32%     
==========================================
  Files          36       36              
  Lines         517      506      -11     
  Branches        3        3              
==========================================
- Hits          454      446       -8     
+ Misses         63       60       -3
Impacted Files Coverage Δ
...b4s/shared/src/main/scala/github4s/Implicits.scala 41.66% <100%> (ø) ⬆️
...ub4s/shared/src/main/scala/github4s/Decoders.scala 100% <100%> (+3.52%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b0911cf...7479799. Read the comment docs.

it should "return an error for an empty list" in {
decode[NonEmptyList[Int]](emptyListResponse) should be('left)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it might be worth it to add a test case for a single element because I think that's why this decoder is here for in the first place.

Something like:

case class Foo(a: Int)
it should "return a valid NonEmtpyList for a valid JSON" in {
  decode[NonEmptyList[Foo]]("""{"a": 1}""") should be(Right(NonEmptyList.of(Foo(1))))
}

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm this seems to be a bit dodgy decoder, converting both A and [A], but as that seems what is needed, I'll add that test 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

agreed, the github api and its quirks ...

Copy link
Member

@juanpedromoreno juanpedromoreno left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @peterneyens !

@juanpedromoreno juanpedromoreno merged commit b0cb5bd into master Apr 28, 2017
@juanpedromoreno juanpedromoreno deleted the peter-traverse branch April 28, 2017 06:08
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.

4 participants