Skip to content

Commit

Permalink
Add mixing refinement and scalaImports
Browse files Browse the repository at this point in the history
  • Loading branch information
lenguyenthanh committed May 30, 2024
1 parent 91b4542 commit 4b33ea7
Showing 1 changed file with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,56 @@ final class RendererSpec extends munit.ScalaCheckSuite {

}

test("mix refinement and scalaImports work") {

val smithy =
"""
|$version: "2.0"
|
|namespace smithy4s
|
|use smithy4s.meta#unwrap
|use smithy4s.meta#refinement
|use smithy4s.meta#scalaImports
|
|@trait(selector: "integer")
|structure SizeFormat { }
|
|apply smithy4s#SizeFormat @refinement(
| targetType: "smithy4s.types.Natural"
| providerImport: "smithy4s.providers._"
|)
|
|@SizeFormat
|@unwrap
|integer Size
|
|structure Input {
|
|@range(min: 1, max: 100)
|size: Size
|
|}
|
|apply smithy4s#Input @scalaImports(
| ["smithy4s.providers._"]
|)
|""".stripMargin

val allContents = generateScalaCode(smithy)

assert(
allContents("smithy4s.Size").contains("import smithy4s.providers._"),
"generated code should contain imports"
)

assert(
allContents("smithy4s.Input").contains("import smithy4s.providers._"),
"generated code should contain imports"
)

}

property("enumeration order is preserved") {

// custom input to avoid scalacheck shrinking
Expand Down

0 comments on commit 4b33ea7

Please sign in to comment.