Skip to content

Commit

Permalink
add tests to assert that code outside com.dwolla.config doesn't have …
Browse files Browse the repository at this point in the history
…access to the generated code
  • Loading branch information
bpholt committed Sep 25, 2024
1 parent 0b48305 commit 2f0257f
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
3 changes: 3 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.typelevel.sbt.gha.WorkflowStep.Sbt

ThisBuild / organization := "com.dwolla"
ThisBuild / description := "Adds support for decrypting values in TypeSafe Config files"
ThisBuild / homepage := Some(url("https://github.com/Dwolla/scala-secure-config"))
Expand Down Expand Up @@ -58,6 +60,7 @@ lazy val `secure-config` = (project in file("."))
"com.disneystreaming.smithy4s" %% "smithy4s-http4s" % smithy4sVersion.value,
"com.disneystreaming.smithy4s" %% "smithy4s-aws-http4s" % smithy4sVersion.value,
"org.typelevel" %% "mouse" % "1.3.1",
"org.scalameta" %% "munit" % "1.0.2" % Test,
)
},
smithy4sAwsSpecs ++= Seq(AWS.kms),
Expand Down
21 changes: 21 additions & 0 deletions src/test/scala-2/bincompat/ShadedGeneratedSmithySpec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package bincompat

import munit.*

class ShadedGeneratedSmithySpec extends FunSuite {
test("we don't have access to the generated KMS objects in their original package") {
assertNoDiff(compileErrors("""com.amazonaws.kms.KMS.id == smithy4s.ShapeId("com.amazonaws.kms", "TrentService")"""),
"""error: object amazonaws is not a member of package com
|com.amazonaws.kms.KMS.id == smithy4s.ShapeId("com.amazonaws.kms", "TrentService")
| ^
|""".stripMargin)
}

test("we don't have access to the generated KMS objects in the shaded package") {
assertNoDiff(compileErrors("""assertEquals(com.dwolla.config.smithy_shaded.com.amazonaws.kms.KMS.id, smithy4s.ShapeId("com.dwolla.config.smithy_shaded.com.amazonaws.kms", "TrentService"))"""),
"""error: value KMS in package kms cannot be accessed as a member of object com.dwolla.config.smithy_shaded.com.amazonaws.kms.package from class ShadedGeneratedSmithySpec in package bincompat
|assertEquals(com.dwolla.config.smithy_shaded.com.amazonaws.kms.KMS.id, smithy4s.ShapeId("com.dwolla.config.smithy_shaded.com.amazonaws.kms", "TrentService"))
| ^
|""".stripMargin)
}
}
31 changes: 31 additions & 0 deletions src/test/scala-3/bincompat/ShadedGeneratedSmithySpec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package bincompat

import munit.*

class ShadedGeneratedSmithySpec extends FunSuite {
test("we don't have access to the generated KMS objects in their original package") {
assertNoDiff(compileErrors("""com.amazonaws.kms.KMS.id == smithy4s.ShapeId("com.amazonaws.kms", "TrentService")"""),
"""error:
|value amazonaws is not a member of com, but could be made available as an extension method.
|
|The following import might make progress towards fixing the problem:
|
| import munit.Clue.generate
|
|com.amazonaws.kms.KMS.id == smithy4s.ShapeId("com.amazonaws.kms", "TrentService")
| ^
|""".stripMargin)
}

test("we don't have access to the generated KMS objects in the shaded package") {
assertNoDiff(compileErrors("""assertEquals(com.dwolla.config.smithy_shaded.com.amazonaws.kms.KMS.id, smithy4s.ShapeId("com.dwolla.config.smithy_shaded.com.amazonaws.kms", "TrentService"))"""),
"""error:
|value KMS in package com.dwolla.config.smithy_shaded.com².amazonaws.kms cannot be accessed as a member of com.dwolla.config.smithy_shaded.com².amazonaws.kms.type from class ShadedGeneratedSmithySpec.
|
|where: com is a package
| com² is a package in package com.dwolla.config.smithy_shaded
|assertEquals(com.dwolla.config.smithy_shaded.com.amazonaws.kms.KMS.id, smithy4s.ShapeId("com.dwolla.config.smithy_shaded.com.amazonaws.kms", "TrentService"))
| ^
|""".stripMargin)
}
}

0 comments on commit 2f0257f

Please sign in to comment.