Skip to content

Commit

Permalink
Added hook that pulls in the config
Browse files Browse the repository at this point in the history
  • Loading branch information
j-mie6 committed Feb 8, 2024
1 parent dd8b9a1 commit 74b017f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package test.golden.scalatest

// this is probably core!
case class GoldenConfig(
accept: Boolean
)
object GoldenConfig {
val default = GoldenConfig(accept = false)
}
8 changes: 0 additions & 8 deletions scalatest/shared/src/main/scala/test/golden/GoldenSuite.scala

This file was deleted.

20 changes: 20 additions & 0 deletions scalatest/shared/src/main/scala/test/golden/HasGoldenConfig.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright 2024 Golden Scala Contributors <https://github.com/j-mie6/golden-scala/graphs/contributors>
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package test.golden.scalatest

import org.scalatest.{Args, Status, Suite}

trait HasGoldenConfig extends Suite {
private [golden] var goldenConfig: GoldenConfig = GoldenConfig.default

abstract override def run(testName: Option[String], args: Args): Status = {
val goldenAccept = args.configMap.getOptional[String]("golden.accept")
.flatMap(_.toBooleanOption)
.getOrElse(false)
goldenConfig = goldenConfig.copy(accept = goldenAccept)
super.run(testName, args)
}
}

0 comments on commit 74b017f

Please sign in to comment.