Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Rob Norris
@tpolecat
we need to find a way to make that work
maybe jon has an idea
(auto/semiauto is an orthogonal concern)
Øyvind Raddum Berg
@oyvindberg
@tpolecat ok, I should probably have made that more explicit in the PR. I think that leaves us with two choices: 1) reintroduce shapeless for those kinds of derivations (I consider it possible that those are relatively speaking much faster to derive than constructing Read/Write for bigger structures), or 2) let the user import the type class derivation of choice, and choose magnolia with that limitation.
or yeah, we can ping Jon, although he pretty much commented in the PR that magnolia doesn't have a satisfactory solution for it now.
Øyvind Raddum Berg
@oyvindberg
Ok, I'm pretty sure I've talked magnolia into supporting this :)
Drew Boardman
@drewboardman
how can I apply a ConnectionIO[T]? I'm trying to write some unit tests and would like to make dummy responses:
protected class TestDbStreamer() extends DBStreamer {
  override def myExampleFunction1: IO[Set[Thing]] = IO.pure(Set.empty[Thing])
  override def myExampleFunction2: ConnectionIO[Set[Thing]] = ConnectionIO.pure(Set.empty[Thing]) // how to do this?
}
Rob Norris
@tpolecat
Set.empty[Thing].pure[ConnectionIO]?
You need cats syntax for that.
Drew Boardman
@drewboardman
::facepalm:: sorry should have tried that
I was looking in the library for an apply()
Rob Norris
@tpolecat
No worries, this is hard.
Drew Boardman
@drewboardman
ty sir
Rob Norris
@tpolecat
Discoverability is low.
Drew Boardman
@drewboardman
the docs are S-tier
really good
Rob Norris
@tpolecat
I'm glad they have been helpful. They need a total rewrite as far as I'm concerned.
Drew Boardman
@drewboardman
are you sunsetting doobie and promoting Skunk for scala 3?
or do you plan to maintain both?
Rob Norris
@tpolecat
Personally I'm using Skunk so that's where my attention is. I will continue to maintain doobie, but there are other maintainers who do most of the work now.
Drew Boardman
@drewboardman
nice
Drew Boardman
@drewboardman

is this the best way to pass a "dummy" transactor to my unit test?

  val dummyTransactor: Aux[IO, Unit] = Transactor.fromDriverManager[IO](
    "org.postgresql.Driver", "jdbc:postgresql:world", "postgres", ""
    )

I just copied it from the docs

This message was deleted
This message was deleted
Rob Norris
@tpolecat
That's actually going to connect to the database.
I would not try to mock out ConnectionIO, there's not much point.
Instead mock your service that uses ConnectionIO.
Drew Boardman
@drewboardman
I'm testing that service
I'll have integration tests that use a DB, but I'd like to unit test some other bits
Rob Norris
@tpolecat
Mocking out the database is high effort and low payoff I think.
Mocking out whatever depends on the database tends to be easier.
jatcwang
@jatcwang:matrix.org
[m]
@drewboardman: if your service exposes IO in its interface instead of ConnectionIO then you shouldnt need a dummy transactor. The downside here is that every method will have to be a separate transaction
Drew Boardman
@drewboardman
what i have is a stream that does a lot of operations. The DB stuff is abstracted and provided to this service
however, I have to transact TWICE in the service, for reasons that are not really possible to fix
so abstracting all the dao bits is a little tough, because I can't just transact at the end
basically, I'm doing an s3.uploadS3FileMultipart that doesn't allow me to stay in ConnectionIO
basically this stream is called transact(transactor) in two places
Drew Boardman
@drewboardman
I'm mocking the results in the unit tests with these test services, I just can't directly mock the result of the transact
jatcwang
@jatcwang:matrix.org
[m]
I'm not familiar with your problem or codebase, but I've been in similar situations and I'm much happier running more integration tests. (It's also a lot more resilient against refactors)
To give you an example, at work I'm using fs2 as well with a lot of timing components (do something every x seconds). I'm testing the system as a whole (including with real database) with integration tests and only mocking external services that I don't control. Using TestContext also allows my test to be deterministic
Drew Boardman
@drewboardman
it actually works with that dummy transactor
Paul Snively
@paul-snively
Repeated dumb question, I'm sure: is there some generic way to map non-case classes, presumably involving reflection?
Let's stipulate "OMG yech don't!"
Rob Norris
@tpolecat
No, not built in. You can do Read[(A, B, C)].imap(... to construct one.
Or if you're just reading you can query[(A, B, C)].map { case (a, b, c) => new Wibble(a, b, c) }
Christopher Davenport
@ChristopherDavenport
@paul-snively Sounds like you're doing something bad over there...
Horace Williams
@worace

I saw there was some previous discussion around the 0.11-0-M1 release with the Magnolia changes so maybe this has all been sorted out, but FWIW I tried it in a medium-sized work project and it all just worked for us.

At one point I did have a funny No Method Error at runtime:

java.lang.NoSuchMethodError: magnolia.Param$.apply(Ljava/lang/String;IZLmagnolia/CallByNeed;Lmagnolia/CallByNeed;[Ljava/lang/Object;[Ljava/lang/Object;)Lmagnolia/Param;

But it went away after a full clean and rebuild, so I'm guessing that was some kind of artifact from a previous version

I was glad to find the instructions in this chat about how to get it from the Sonatype OSS Local resolver b/c I was having trouble finding it before
Øyvind Raddum Berg
@oyvindberg
@worace good to hear that it seems to work. That exception seems to be tracked here propensive/magnolia#266 and it's probably caused by some parts of your code compiled with old magnolia.
Also there is a PR now with the missing Put/Get instances for wrapper types at tpolecat/doobie#1350 . I'll try to lobby a bit more to include the necessary functionality into magnolia itself rather than adding a macro. But it's good that it wasn't too hard to add