Skip to content

Remove mocking from tests; use http4s directly #669

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
Jul 6, 2021
Merged

Remove mocking from tests; use http4s directly #669

merged 1 commit into from
Jul 6, 2021

Conversation

Daenyth
Copy link
Contributor

@Daenyth Daenyth commented Jul 6, 2021

This is needed for scala3

This PR was extracted from #667

This adds explicit circe encoders and decoders; no more auto-derivation.

This is needed for the new tests, which have to be able to round trip responses through http entities, rather than mocking at the object level.

@codecov
Copy link

codecov bot commented Jul 6, 2021

Codecov Report

Merging #669 (6e6d092) into main (92e4353) will increase coverage by 4.30%.
The diff coverage is 99.47%.

❗ Current head 6e6d092 differs from pull request most recent head b5421dc. Consider uploading reports for the commit b5421dc to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main     #669      +/-   ##
==========================================
+ Coverage   90.54%   94.84%   +4.30%     
==========================================
  Files          25       25              
  Lines         645      815     +170     
  Branches        1        2       +1     
==========================================
+ Hits          584      773     +189     
+ Misses         61       42      -19     
Impacted Files Coverage Δ
github4s/src/main/scala/github4s/Decoders.scala 98.92% <98.27%> (+7.37%) ⬆️
github4s/src/main/scala/github4s/Encoders.scala 100.00% <100.00%> (+3.22%) ⬆️
...ub4s/src/main/scala/github4s/http/HttpClient.scala 97.56% <0.00%> (+4.87%) ⬆️
...s/src/main/scala/github4s/domain/SearchParam.scala 59.09% <0.00%> (+27.27%) ⬆️

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 8b5cf66...b5421dc. Read the comment docs.

@Daenyth Daenyth marked this pull request as ready for review July 6, 2021 13:12

import scala.reflect.ClassTag

class EncoderDecoderSpec extends AnyFlatSpec with ScalaCheckPropertyChecks {
Copy link
Member

Choose a reason for hiding this comment

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

Why is this test in the scala-2 directory? You've included ArbitraryDerivation for both Scala 2 or 3 - is there some other dependency that's missing for Scala 3?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

scalacheck-shapeless doesn't exist for scala3, since on scala3, shapeless isn't out.

I put the spec in scala2 because I ran into what I think might be a compiler bug, preventing me from using the (otherwise working) scala-3 ArbitraryDerivation.

scala/scala3#13001

@Daenyth Daenyth merged commit a8f7853 into main Jul 6, 2021
@Daenyth Daenyth deleted the gb-mockito branch July 6, 2021 13:59
implicit val decoderCommentData: Decoder[CommentData] = deriveDecoder[CommentData]
implicit val decoderPullRequestReviewEvent: Decoder[PullRequestReviewEvent] =
Decoder[String].emap {
case s if s == PRREventApprove.value => Right(PRREventApprove)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
case s if s == PRREventApprove.value => Right(PRREventApprove)
case PRREventApprove.value => Right(PRREventApprove)

wouldn't work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would work. I think this was existing code that got shuffled around, and I left it as-is


object auto {
given deriveArb[A](using gen: DerivedGen[A]): Arbitrary[A] = gen.arb
}
Copy link
Contributor

Choose a reason for hiding this comment

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

should we harmonize brackets / no brackets?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you elaborate on what you mean by that? Do you mean using a set of empty parens? Typically you wouldn't do that.

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 Ben is referring to the inconsistent use of significant whitespace vs braces in this file. e.g. object semiauto: vs object auto { ... }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah gotcha, that makes sense.

I don't have a strong opinion on it. The indentation-based parts were mostly what I copied from some folks helping me out in discord. I don't have a sense for what is best to move forward with.

Honestly, I hope this file gets deleted before it matters. The behavior shouldn't be defined here at all, but rather upstream

val scalamock: String = "5.1.0"
val scalatest: String = "3.2.9"
val silencer: String = "1.7.1"
val bm4 = "0.3.1"
Copy link
Contributor

Choose a reason for hiding this comment

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

is this used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's better-monadic-for. I forget where exactly, but it's compile-time-only, so it doesn't hurt to have in the project. It just makes things work better regardless

@BenFradet
Copy link
Contributor

didn't check the whole pr

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.

3 participants