-
-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for ArgBuilder with when input is a value type (#2323)
* Fix for ArgBuilder with value types * Add test for derivation of AnyVal ArgBuilder
- Loading branch information
1 parent
1a4f14a
commit ce502f6
Showing
4 changed files
with
72 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
core/src/test/scala-2/caliban/schema/ArgBuilderScala2Spec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package caliban.schema | ||
|
||
import caliban.Value.StringValue | ||
import caliban.schema.ArgBuilder.auto._ | ||
import zio.test.Assertion._ | ||
import zio.test._ | ||
|
||
import java.util.UUID | ||
|
||
object ArgBuilderScala2Spec extends ZIOSpecDefault { | ||
def spec = suite("ArgBuilderScala2")( | ||
suite("AnyVal") { | ||
test("ArgBuilder that extends AnyVal") { | ||
val id = UUID.randomUUID() | ||
val value = ArgBuilder[UUIDId].build(StringValue(id.toString)) | ||
assert(value)(isRight(equalTo(UUIDId(id)))) | ||
} | ||
} | ||
) | ||
|
||
trait Ids[T] extends Any { | ||
self: AnyVal => | ||
def value: T | ||
} | ||
|
||
final case class UUIDId(value: UUID) extends AnyVal with Ids[UUID] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters