Skip to content

Commit

Permalink
Add JSON golden test example
Browse files Browse the repository at this point in the history
  • Loading branch information
keynmol committed Feb 13, 2024
1 parent a3b4074 commit 926f371
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 17 deletions.
33 changes: 16 additions & 17 deletions .scalafmt.conf
@@ -1,25 +1,24 @@
version = "3.7.17"

runner.dialect = scala212source3
# rewrite.scala3.insertEndMarkerMinLines = 10
# rewrite.scala3.removeOptionalBraces = true
# rewrite.scala3.convertToNewSyntax = true
align.preset = more

# fileOverride {
# "glob:**.sbt" {
# runner.dialect = scala212source3
# }
fileOverride {
# "glob:**.sbt" {
# runner.dialect = scala212source3
# }

# "glob:**/project/**.*" {
# runner.dialect = scala212source3
# }
# "glob:**/project/**.*" {
# runner.dialect = scala212source3
# }

# "glob:**/snapshots-sbt-plugin/**.*" {
# runner.dialect = scala212source3
# }
# "glob:**/snapshots-sbt-plugin/**.*" {
# runner.dialect = scala212source3

# "glob:**/snapshots-buildtime/**.*" {
# runner.dialect = scala212source3
# }
# }
"glob:**/scala-3/**.*" {
runner.dialect = scala3
rewrite.scala3.insertEndMarkerMinLines = 10
rewrite.scala3.removeOptionalBraces = true
rewrite.scala3.convertToNewSyntax = true
}
}
1 change: 1 addition & 0 deletions build.sbt
Expand Up @@ -78,6 +78,7 @@ lazy val example = projectMatrix
snapshotsPackageName := "example",
snapshotsAddRuntimeDependency := false,
snapshotsIntegrations += SnapshotIntegration.MUnit,
libraryDependencies += "io.circe" %%% "circe-core" % "0.14.6",
noPublish
)
.enablePlugins(SnapshotsPlugin)
Expand Down
@@ -0,0 +1,8 @@
{
"Hello" : {
"a" : 25,
"b" : {
"s" : "yo"
}
}
}
15 changes: 15 additions & 0 deletions modules/example/src/test/scala-3/JsonGoldenTests.scala
@@ -0,0 +1,15 @@
import com.indoorvivants.snapshots.munit_integration.*
import munit.*

import io.circe.*, io.circe.syntax.*

case class Test(s: String)
enum MyStuff derives Codec.AsObject:
case Hello(a: Int, b: Test)
case Bla(x: Boolean)

class JsonGoldenTests extends FunSuite with MunitSnapshotsIntegration:
test("json tests") {
val obj = MyStuff.Hello(25, Test("yo"))
assertSnapshot("json.codec", obj.asJson.spaces4)
}

0 comments on commit 926f371

Please sign in to comment.