Skip to content

Commit

Permalink
Sample of a generation failure..
Browse files Browse the repository at this point in the history
  • Loading branch information
aoiroaoino committed Sep 5, 2024
1 parent 355fd0d commit 199dc9f
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions modules/scala-http4s/src/test/scala/core/issues/IssueN.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package core.issues

import dev.guardrail.Context
import dev.guardrail.generators.scala.ScalaGeneratorMappings.scalaInterpreter
import dev.guardrail.generators.scala.http4s.Http4sVersion
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers
import support.SwaggerSpecRunner
import scala.meta._

class IssueN extends AnyFunSuite with Matchers with SwaggerSpecRunner {
val spec: String = """openapi: 3.0.2
|components:
| schemas:
| FooBarType:
| type: string
| enum:
| - A
| - B
| foo_type:
| type: array
| nullable: false
| items:
| allOf:
| - $ref: '#/components/schemas/FooBarType'
|""".stripMargin

def testVersion(version: Http4sVersion): Unit =
test(s"$version - Test correct escaping of numbers used as identifiers") {
val actual = runSwaggerSpec(scalaInterpreter)(spec)(Context.empty, version.value)
succeed
}

// testVersion(Http4sVersion.V0_22)
testVersion(Http4sVersion.V0_23)
}

1 comment on commit 199dc9f

@aoiroaoino
Copy link
Owner Author

Choose a reason for hiding this comment

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

sbt:guardrail-root> guardrail-scala-http4s/testOnly *IssueN
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.
[info] IssueN:
[info] - V0_23 - Test correct escaping of numbers used as identifiers *** FAILED ***
[info]   java.lang.Exception: UserError(Unknown type for the following structure (No type definition, class: io.swagger.v3.oas.models.media.ComposedSchema, .components.schemas.foo_type.items):
[info]   Tracker(class ComposedSchema {
[info]       class Schema {
[info]       }
[info]   }, Vector(.components, .schemas, .foo_type, .items))
[info] )
[info]   at support.SwaggerSpecRunner.$anonfun$runSwagger$2(SwaggerSpecRunner.scala:85)
[info]   at dev.guardrail.TargetError.valueOr(Target.scala:114)
[info]   at support.SwaggerSpecRunner.$anonfun$runSwagger$1(SwaggerSpecRunner.scala:84)
[info]   at cats.data.NonEmptyList.map(NonEmptyList.scala:109)
[info]   at support.SwaggerSpecRunner.support$SwaggerSpecRunner$$runSwagger(SwaggerSpecRunner.scala:75)
[info]   at support.SwaggerSpecRunner$$anon$1.$anonfun$apply$2(SwaggerSpecRunner.scala:63)
[info]   at dev.guardrail.TargetValue.map(Target.scala:108)
[info]   at support.SwaggerSpecRunner$$anon$1.$anonfun$apply$1(SwaggerSpecRunner.scala:59)
[info]   at dev.guardrail.TargetValue.flatMap(Target.scala:107)
[info]   at support.SwaggerSpecRunner$$anon$1.apply(SwaggerSpecRunner.scala:58)
[info]   ...
[info] Run completed in 546 milliseconds.
[info] Total number of tests run: 1
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 0, failed 1, canceled 0, ignored 0, pending 0
[info] *** 1 TEST FAILED ***
[error] Failed tests:
[error] 	core.issues.IssueN
[error] (guardrail-scala-http4s / Test / testOnly) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 1 s, completed 2024/09/05 16:07:30

Please sign in to comment.