Skip to content

Commit

Permalink
Fix Tests, Prepare for Scala 2.13
Browse files Browse the repository at this point in the history
  • Loading branch information
fdietze committed Aug 12, 2020
1 parent 2e77315 commit 6d2baa2
Show file tree
Hide file tree
Showing 29 changed files with 135 additions and 135 deletions.
20 changes: 5 additions & 15 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// shadow sbt-scalajs' crossProject and CrossType until Scala.js 1.0.0 is released
import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType}

name := "wust"

// docker versions do not allow '+'
Expand All @@ -10,8 +7,8 @@ dynver in ThisBuild ~= (_.replace('+', '-')) // TODO: https://github.com/dwijnan
import Def.{setting => dep}

// -- common setting --
crossScalaVersions in ThisBuild := Seq("2.12.12")
scalaVersion in ThisBuild := crossScalaVersions.value.last
scalaVersion in ThisBuild := "2.12.12"


Global / onChangedBuildSource := IgnoreSourceChanges // disabled, since it doesn't recover state of devserver

Expand All @@ -31,6 +28,9 @@ lazy val commonSettings = Seq(
Deps.sourcecode.value ::
Deps.scalatest.value % Test ::
Deps.mockito.value % Test ::
Deps.scalatestFreespec.value % Test ::
Deps.scalatestMustmatchers.value % Test ::
Deps.scalatestMockito.value % Test ::
Nil,
dependencyOverrides ++= List(
Deps.circe.core.value,
Expand Down Expand Up @@ -72,17 +72,12 @@ lazy val commonSettings = Seq(
"-feature" ::
"-language:_" ::
"-Xfuture" ::
"-Yno-adapted-args" ::
"-Ywarn-infer-any" ::
"-Ywarn-nullary-override" ::
"-Ywarn-nullary-unit" ::
// "-opt-warnings:at-inline-failed" ::
"-Xlint:_" ::
"-Ywarn-unused:-imports" ::
// "-Ywarn-self-implicit" ::
// "-Ywarn-dead-code" :: // does not work well with scalajs js.native in facades
"-Ywarn-extra-implicit" ::
"-P:silencer:checkUnused" ::
"-Ypatmat-exhaust-depth" :: "off" :: // needed for huge match in FeatureDetails
Nil,

Expand Down Expand Up @@ -115,11 +110,6 @@ lazy val commonSettings = Seq(
// scalacOptions in Test ~= (_ filterNot (_ == "-Xplugin-require:scalaxy-streams")),
// scalacOptions in Test += "-Xplugin-disable:scalaxy-streams",
// addCompilerPlugin("com.github.fdietze" % "scalaxy-streams" % "2.12-819f13722a-1"), //TODO: https://github.com/nativelibs4java/scalaxy-streams/pull/13

libraryDependencies ++= Seq(
compilerPlugin("com.github.ghik" %% "silencer-plugin" % Deps.silencerVersion),
"com.github.ghik" %% "silencer-lib" % Deps.silencerVersion % Provided
)
)

lazy val commonWebSettings = Seq(
Expand Down
5 changes: 3 additions & 2 deletions core/src/main/scala/wust/core/Server.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import java.nio.ByteBuffer

import akka.actor.ActorSystem
import akka.util.ByteStringBuilder
import ch.megard.akka.http.cors.scaladsl.model.HttpOriginMatcher
import akka.http.scaladsl.marshalling.{Marshaller, ToResponseMarshaller}
import akka.http.scaladsl.model.headers.HttpOriginRange
import akka.http.scaladsl.model.{ContentTypes, HttpEntity, HttpResponse, StatusCodes}
Expand Down Expand Up @@ -49,7 +50,7 @@ object Server {

val route = createRoute(config)

Http().bindAndHandle(route, interface = "0.0.0.0", port = config.server.port).onComplete {
Http().newServerAt("0.0.0.0", config.server.port).bindFlow(route).onComplete {
case Success(binding) => {
val separator = "\n" + ("#" * 50)
val readyMsg = s"\n##### Server online at ${binding.localAddress} #####"
Expand Down Expand Up @@ -108,7 +109,7 @@ object Server {
val (protocol,port) = if (config.server.host == "localhost") ("http://", ":12345") else ("https://", "")
s"${protocol}${config.server.host}${port}"
}
val corsSettings = CorsSettings.defaultSettings.withAllowedOrigins(HttpOriginRange(websiteOrigin))
val corsSettings = CorsSettings.defaultSettings.withAllowedOrigins(HttpOriginMatcher(websiteOrigin))

implicit val jsonMarshaller: ToResponseMarshaller[String] =
Marshaller.withFixedContentType(ContentTypes.`application/json`) { s =>
Expand Down
1 change: 1 addition & 0 deletions core/src/main/scala/wust/core/config/Config.scala
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ final case class Config(
object Config {
import pureconfig._
import wust.util.Config._
import pureconfig.generic.auto._

def load = loadConfig[Config]("wust.core")
}
2 changes: 1 addition & 1 deletion core/src/test/scala/wust/core/ApiImplSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// import java.time.LocalDateTime
// import scala.concurrent.duration._

// class ApiImplSpec extends AsyncFreeSpec with MustMatchers with ApiTestKit {
// class ApiImplSpec extends AsyncFreeSpec with must.Matchers with ApiTestKit {

// object User {
// def apply(id: Long, name: String): User = new User(id, name, isImplicit = false, 0)
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/scala/wust/core/AuthApiImplSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// import scala.concurrent.duration._
// import com.roundeights.hasher.Hasher

// class AuthApiImplSpec extends AsyncFreeSpec with MustMatchers with ApiTestKit {
// class AuthApiImplSpec extends AsyncFreeSpec with must.Matchers with ApiTestKit {
// implicit def passwordToDigest(pw: String): Array[Byte] = Hasher(pw).bcrypt
// // implicit class EqualityByteArray(val arr: Array[Byte]) {
// // def mustEqualDigest(pw: String) = assert(passwordToDigest(pw)
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/scala/wust/core/GuardDslSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// import scala.concurrent.Future
// import scala.concurrent.duration._

// class GuardDslSpec extends AsyncFreeSpec with MustMatchers with DbMocks {
// class GuardDslSpec extends AsyncFreeSpec with must.Matchers with DbMocks {
// val implicitUserDb = Data.User(14, "implicit", isImplicit = true, 0)
// val implicitUser = DbConversions.forClient(implicitUserDb)
// val initialUser = User(11, "existing", isImplicit = false, 0)
Expand Down
4 changes: 3 additions & 1 deletion core/src/test/scala/wust/core/JWTSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ package wust.core
import java.time.Instant

import org.scalatest._
import org.scalatest.matchers._
import org.scalatest.freespec.AnyFreeSpec
import wust.api.{AuthUser, Authentication}
import wust.core.auth.JWT
import wust.ids._

import scala.concurrent.duration._

class JWTSpec extends FreeSpec with MustMatchers {
class JWTSpec extends AnyFreeSpec with must.Matchers {
val jwt = new JWT("secret", 1 hours)

def User(name: String): AuthUser.Persisted = new AuthUser.Real(UserId.fresh, name, 0, None)
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/scala/wust/core/Mocks.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package wust.core

import org.mockito.Mockito
import org.scalatest.mockito.MockitoSugar
import wust.db.Db

import scala.concurrent.Future
import org.scalatestplus.mockito.MockitoSugar

trait SpecsLikeMockito extends MockitoSugar {
class MockitoMock[T](method: T) {
Expand Down
2 changes: 1 addition & 1 deletion database/src/it/scala/wust/db/DbSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
// }
//}

//class DbSpec extends DbIntegrationTestSpec with MustMatchers {
//class DbSpec extends DbIntegrationTestSpec with must.Matchers {
// import DbSpec._
// implicit def passwordToDigest(pw: String): Array[Byte] = pw.map(_.toByte).toArray
// implicit class EqualityByteArray(val arr: Array[Byte]) {
Expand Down
4 changes: 3 additions & 1 deletion graph/src/test/scala/wust/graph/GraphSpec.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package wust.graph

import org.scalatest._
import org.scalatest.matchers._
import org.scalatest.freespec.AnyFreeSpec
import wust.ids._

class GraphSpec extends FreeSpec with MustMatchers {
class GraphSpec extends AnyFreeSpec with must.Matchers {
implicit def intToNodeId(id: Int): NodeId = NodeId(Cuid(id, 0))
implicit def idToNode(id: Int): Node = Node.Content(id = id, data = NodeData.PlainText("content"), role = NodeRole.default, meta = NodeMeta(NodeAccess.ReadWrite))
implicit def nodeListToMap(nodes: List[Int]): List[Node] = nodes.map(idToNode)
Expand Down
5 changes: 0 additions & 5 deletions ids/src/main/scala/wust/ids/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package wust
import java.util.Date
import java.time.{LocalDateTime, ZonedDateTime, ZoneOffset, Instant}

import com.github.ghik.silencer.silent
import supertagged._

import scala.util.Try
Expand Down Expand Up @@ -83,7 +82,6 @@ package object ids {
@inline def now: EpochMilli = localNow plus delta
@inline def zero: EpochMilli = EpochMilli(0L)

@silent("deprecated")
def parse(str: String) = Try(Date.parse(str)).toOption.map(EpochMilli(_))

def fromDate(d: Date): EpochMilli = EpochMilli(d.toInstant.toEpochMilli)
Expand All @@ -108,7 +106,6 @@ package object ids {
@inline def toLocalDateTime: LocalDateTime = toZonedDateTime.toLocalDateTime
def toZonedDateTime: ZonedDateTime = Instant.ofEpochMilli(t).atZone(ZoneOffset.UTC)

@silent("deprecated")
def humanReadable: String = {
// java.util.Date is deprecated, but implemented in java and scalajs
// and therefore a simple cross-compiling solution
Expand All @@ -123,7 +120,6 @@ package object ids {
f"$year%04d-$month%02d-$day%02d $hour%02d:$minute%02d:$second%02d"
}

@silent("deprecated")
def isoDate: String = {
// java.util.Date is deprecated, but implemented in java and scalajs
// and therefore a simple cross-compiling solution
Expand All @@ -135,7 +131,6 @@ package object ids {
f"$year%04d-$month%02d-$day%02d"
}

@silent("deprecated")
def isoDateAndTime: String = {
// java.util.Date is deprecated, but implemented in java and scalajs
// and therefore a simple cross-compiling solution
Expand Down
4 changes: 3 additions & 1 deletion ids/src/test/scala/wust/ids/CuidSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package wust.ids
import java.util.UUID

import org.scalatest._
import org.scalatest.matchers._
import org.scalatest.freespec.AnyFreeSpec

class CuidSpec extends FreeSpec with MustMatchers {
class CuidSpec extends AnyFreeSpec with must.Matchers {
"uuid" in {
val original = new UUID(12, 25)
val bag = Cuid.fromUuid(original)
Expand Down
29 changes: 15 additions & 14 deletions project/Deps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ import sbt._
object Deps {
import Def.{ setting => dep }

val silencerVersion = "1.4.2"

val acyclicDef = "com.lihaoyi" %% "acyclic" % "0.1.9"
val acyclicDef = "com.lihaoyi" %% "acyclic" % "0.2.0"
val acyclic = dep(acyclicDef % "provided")

// testing
val scalatest = dep("org.scalatest" %%% "scalatest" % "3.2.0")
val scalatestFreespec = dep("org.scalatest" %%% "scalatest-freespec" % "3.2.0")
val scalatestMustmatchers = dep("org.scalatest" %%% "scalatest-mustmatchers" % "3.2.0")
val scalatestMockito = dep("org.scalatestplus" %% "mockito-3-3" % "3.2.0.0")
val mockito = dep("org.mockito" % "mockito-core" % "2.28.2")
val selenium = dep("org.seleniumhq.selenium" % "selenium-java" % "3.3.1")
val specs2 = dep("org.specs2" %% "specs2-core" % "4.7.0")
val mockito = dep("org.mockito" % "mockito-core" % "2.28.2")

// core libraries
val cats = new {
Expand All @@ -22,12 +23,12 @@ object Deps {
}
val akka = new {
private val version = "2.6.6"
private val httpVersion = "10.1.12"
private val httpVersion = "10.2.0"
val http = dep("com.typesafe.akka" %% "akka-http" % httpVersion)
val httpCore = dep("com.typesafe.akka" %% "akka-http-core" % httpVersion)
val httpCirce = dep("de.heikoseeberger" %% "akka-http-circe" % "1.30.0")
val httpPlay = dep("de.heikoseeberger" %% "akka-http-play-json" % "1.30.0")
val httpCors = dep("ch.megard" %% "akka-http-cors" % "0.3.1")
val httpCors = dep("ch.megard" %% "akka-http-cors" % "1.1.0")
val stream = dep("com.typesafe.akka" %% "akka-stream" % version)
val actor = dep("com.typesafe.akka" %% "akka-actor" % version)
val testkit = dep("com.typesafe.akka" %% "akka-testkit" % version)
Expand All @@ -50,7 +51,7 @@ object Deps {
val scalaJsDom = dep("org.scala-js" %%% "scalajs-dom" % "1.0.0")
val d3v4 = dep("com.github.fdietze.scala-js-d3v4" %%% "scala-js-d3v4" % "809f086")
// val d3v4 = dep("com.github.fdietze" %%% "scala-js-d3v4" % "master-SNAPSHOT")
val fontawesome = dep("com.github.fdietze" % "scala-js-fontawesome" % "308e305")
val fontawesome = dep("com.github.fdietze.scala-js-fontawesome" %%% "scala-js-fontawesome" % "559c7f7")
val vectory = dep("com.github.fdietze.vectory" %%% "vectory" % "14bf5d2")
val scalarx = dep("com.lihaoyi" %%% "scalarx" % "0.4.3")
val outwatch = new {
Expand All @@ -65,23 +66,22 @@ object Deps {
val monix = dep("com.github.cornerman.colibri" %%% "colibri-monix" % version)
val rx = dep("com.github.cornerman.colibri" %%% "colibri-rx" % version)
}
val bench = dep("com.github.fdietze.bench" %%% "bench" % "e66a721")
// val bench = dep("com.github.fdietze" %%% "bench" % "master-SNAPSHOT")
val bench = dep("com.github.fdietze.bench" %%% "bench" % "087e511")

// utility
val scribe = new {
// TODO: val perfolation = dep("com.github.fdietze.perfolation" %%% "perfolation" % "6854947")
val core = dep("com.outr" %%% "scribe" % "2.7.12")
}
val pureconfig = dep("com.github.pureconfig" %% "pureconfig" % "0.9.2")
val pureconfig = dep("com.github.pureconfig" %% "pureconfig" % "0.11.1") // https://github.com/pureconfig/pureconfig/blob/master/CHANGELOG.md
val monocle = dep("com.github.julien-truffaut" %% "monocle-macro" % "2.0.0")
val monocleCore = dep("com.github.julien-truffaut" %% "monocle-core" % "2.0.0")
val sourcecode = dep("com.lihaoyi" %%% "sourcecode" % "0.2.1")
val cuid = dep("io.github.cornerman.scala-cuid" %%% "scala-cuid" % "b980489")
val base58s = dep("io.github.fdietze.base58s" %%% "base58s" % "43d5684")
val monix = dep("io.monix" %%% "monix" % "3.2.2")
// val taggedTypes = dep("org.rudogma" %%% "supertagged" % "2.0-RC1")
val taggedTypes = dep("com.github.lolgab" % "scala-supertagged" % "scalajs-1.0.0-RC2-SNAPSHOT")
val taggedTypes = dep("com.github.fdietze.scala-supertagged" %%% "supertagged" % "0157b28") // until https://github.com/rudogma/scala-supertagged/pull/2 is merged
val colorado = dep("com.github.fdietze.colorado" %%% "colorado" % "d36c389")
val scalacss = dep("com.github.japgolly.scalacss" %%% "core" % "0.6.1")
val kantanRegex = new {
Expand Down Expand Up @@ -109,16 +109,17 @@ object Deps {
}

// auth
val hasher = dep("com.roundeights" %% "hasher" % "1.2.0")
//val hasher = dep("com.roundeights" %% "hasher" % "1.2.0") //TODO: https://github.com/Nycto/Hasher/pull/28
val hasher = dep("com.github.fdietze.hasher" %% "hasher" % "75be8ed")
val jbcrypt = dep("org.mindrot" % "jbcrypt" % "0.4")
val jwt = dep("com.pauldijou" %% "jwt-circe" % "4.2.0")
val bouncyCastle = dep("org.bouncycastle" % "bcpkix-jdk15on" % "1.60")
val oAuthServer = dep("com.nulab-inc" %% "scala-oauth2-core" % "1.3.0")
val oAuthAkkaProvider = dep("com.nulab-inc" %% "akka-http-oauth2-provider" % "1.3.0")
val oAuthClient = dep("com.github.fdietze" % "akka-http-oauth2-client" % "cf77841")
val oAuthClient = dep("com.github.fdietze.akka-http-oauth2-client" %% "akka-http-oauth2-client" % "dd8e734")

// database
val quill = dep("io.getquill" %% "quill-async-postgres" % "3.2.2")
val quill = dep("io.getquill" %% "quill-async-postgres" % "3.5.2")

// interfaces
//val github4s = dep("com.47deg" %% "github4s" % "0.17.0") // only temporarly here
Expand Down
1 change: 1 addition & 0 deletions sdk/jvm/src/main/scala/wust/sdk/Config.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ final case class DefaultConfig(appServer: ServerConfig, wustServer: WustConfig,

object Config {
import pureconfig._
import pureconfig.generic.auto._
import pureconfig.error.ConfigReaderFailures
import wust.util.Config._

Expand Down
Loading

0 comments on commit 6d2baa2

Please sign in to comment.