Skip to content

Commit a161834

Browse files
committed
make tests independent
1 parent 0b2b5cd commit a161834

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

rest/.jvm/src/test/scala/io/udash/rest/SttpRestCallTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import io.udash.rest.raw.HttpErrorException
55
import io.udash.rest.raw.RawRest.HandleRequest
66
import sttp.client3.SttpBackend
77

8-
import scala.concurrent.duration._
8+
import scala.concurrent.duration.*
99
import scala.concurrent.{Await, Future}
1010

1111
trait SttpClientRestTest extends ServletBasedRestApiTest {

rest/src/test/scala/io/udash/rest/RestApiTest.scala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@ import org.scalatest.funsuite.AnyFunSuite
1515
import scala.concurrent.duration.FiniteDuration
1616

1717
abstract class RestApiTest extends AnyFunSuite with ScalaFutures {
18-
1918
protected final val MaxConnections: Int = 1 // to timeout quickly
2019
protected final val Connections: Int = 10 // > MaxConnections
2120
protected final val CallTimeout: FiniteDuration = 300.millis // << idle timeout
2221

2322
implicit def scheduler: Scheduler = Scheduler.global
2423

24+
private val impl: RestTestApi = RestTestApi.Impl
25+
2526
final val serverHandle: RawRest.HandleRequest =
26-
RawRest.asHandleRequest[RestTestApi](RestTestApi.Impl)
27+
RawRest.asHandleRequest[RestTestApi](impl)
2728

2829
def clientHandle: RawRest.HandleRequest
2930

@@ -33,16 +34,16 @@ abstract class RestApiTest extends AnyFunSuite with ScalaFutures {
3334
def testCall[T](call: RestTestApi => Future[T])(implicit pos: Position): Unit =
3435
assert(
3536
call(proxy).wrapToTry.futureValue.map(mkDeep) ==
36-
call(RestTestApi.Impl).catchFailures.wrapToTry.futureValue.map(mkDeep)
37+
call(impl).catchFailures.wrapToTry.futureValue.map(mkDeep)
3738
)
3839

3940
def mkDeep(value: Any): Any = value match {
4041
case arr: Array[_] => IArraySeq.empty[AnyRef] ++ arr.iterator.map(mkDeep)
4142
case _ => value
4243
}
4344

44-
def getNeverGetCounter(): Int = RestTestApi.Impl.neverGetCounter.get()
45-
def resetNeverGetCounter(): Unit = RestTestApi.Impl.neverGetCounter.set(0)
45+
def getNeverGetCounter(): Int = impl.neverGetCounter.get()
46+
def resetNeverGetCounter(): Unit = impl.neverGetCounter.set(0)
4647
}
4748

4849
trait RestApiTestScenarios extends RestApiTest {

rest/src/test/scala/io/udash/rest/RestTestApi.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ object RestTestApi extends DefaultRestApiCompanion[RestTestApi] {
179179

180180
import Scheduler.Implicits.global
181181

182-
val Impl: RestTestApi = new RestTestApi {
182+
def Impl: RestTestApi = new RestTestApi {
183183
def trivialGet: Future[Unit] = Future.unit
184184
def failingGet: Future[Unit] = Future.failed(HttpErrorException.plain(503, "nie"))
185185
def jsonFailingGet: Future[Unit] = Future.failed(HttpErrorException(503, HttpBody.json(JsonValue(JsonStringOutput.write(ErrorWrapper("nie"))))))

0 commit comments

Comments
 (0)