-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: changed all test from spec2 to munit
- Loading branch information
1 parent
73b7e40
commit 9cd33ce
Showing
70 changed files
with
1,994 additions
and
2,295 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Test / parallelExecution := false | ||
|
||
libraryDependencies += "org.liquibase" % "liquibase-core" % "4.31.0" % Test | ||
|
||
// Test | ||
|
||
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.5.16" % Test | ||
|
||
libraryDependencies += "org.scalameta" %% "munit" % "1.1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,2 @@ | ||
docker rm -f mongodb; | ||
docker run -d --publish 27017:27017 --name mongodb mongocamp/mongodb:latest; | ||
|
||
|
||
# | ||
# [error] Error during tests: | ||
# [error] dev.mongocamp.driver.mongodb.sync.SyncSpec | ||
# [error] dev.mongocamp.driver.mongodb.sql.SelectSqlSpec | ||
# [error] dev.mongocamp.driver.mongodb.dao.StudentDAOSpec | ||
# [error] dev.mongocamp.driver.mongodb.sql.OtherSqlSpec | ||
docker run -d --publish 27017:27017 --name mongodb mongocamp/mongodb:latest; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 0 additions & 108 deletions
108
src/test/scala/dev/mongocamp/driver/mongodb/bson/BsonConverterSpec.scala
This file was deleted.
Oops, something went wrong.
93 changes: 93 additions & 0 deletions
93
src/test/scala/dev/mongocamp/driver/mongodb/bson/BsonConverterSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package dev.mongocamp.driver.mongodb.bson | ||
|
||
import com.typesafe.scalalogging.LazyLogging | ||
import dev.mongocamp.driver.mongodb._ | ||
import org.mongodb.scala.bson.collection.mutable | ||
import org.mongodb.scala.bson.{ ObjectId, _ } | ||
|
||
import scala.collection.mutable.ArrayBuffer | ||
|
||
class BsonConverterSuite extends munit.FunSuite { | ||
|
||
test("BsonConverter convert values to BSON") { | ||
assertEquals(BsonConverter.toBson(3), BsonInt32(3)) | ||
assertEquals(BsonConverter.toBson(3L), BsonInt64(3)) | ||
assertEquals(BsonConverter.toBson(3f), BsonDouble(3)) | ||
assertEquals(BsonConverter.toBson(3d), BsonDouble(3)) | ||
|
||
assertEquals(BsonConverter.toBson(false), BsonBoolean(false)) | ||
assertEquals(BsonConverter.toBson(true), BsonBoolean(true)) | ||
|
||
assertEquals(BsonConverter.toBson(java.math.BigDecimal.TEN), BsonDecimal128.apply(10)) | ||
assertEquals(BsonConverter.toBson(BigDecimal(10)), BsonDecimal128.apply(10)) | ||
assertEquals(BsonConverter.toBson(BigInt(10)), BsonInt64(10)) | ||
assertEquals(BsonConverter.toBson(java.math.BigInteger.TEN), BsonInt64(10)) | ||
|
||
assertEquals(BsonConverter.toBson(Some(5)), BsonInt32(5)) | ||
|
||
assertEquals(BsonConverter.toBson(Some(new ObjectId("5b61455932ac3f0015ae2e7e"))), BsonObjectId("5b61455932ac3f0015ae2e7e")) | ||
|
||
assertEquals(BsonConverter.toBson(None), BsonNull()) | ||
|
||
assertEquals(BsonConverter.toBson('M'), BsonString("M")) | ||
} | ||
|
||
test("convert Map to BSON") { | ||
assertEquals(BsonConverter.toBson(Map("test" -> 1)).isInstanceOf[org.bson.BsonDocument], true) | ||
assertEquals(BsonConverter.toBson(scala.collection.mutable.Map("test" -> 1)).isInstanceOf[org.bson.BsonDocument], true) | ||
} | ||
|
||
test("convert List to BSON") { | ||
assertEquals(BsonConverter.toBson(List("test")).isInstanceOf[org.bson.BsonArray], true) | ||
val buffer = new ArrayBuffer[String]() | ||
buffer.+=("Test") | ||
assertEquals(BsonConverter.toBson(buffer).isInstanceOf[org.bson.BsonArray], true) | ||
} | ||
|
||
test("convert values from BSON") { | ||
assertEquals(BsonConverter.fromBson(BsonInt32(3)), 3) | ||
assertEquals(BsonConverter.fromBson(BsonInt64(3)), 3L) | ||
assertEquals(BsonConverter.fromBson(BsonDouble(3)), 3.0) | ||
} | ||
|
||
test("evaluate dot notation") { | ||
val document: mutable.Document = mutable.Document() | ||
val secondLevelDocument = mutable.Document() | ||
secondLevelDocument.put("test", 42) | ||
document.put("secondLevelDocument", secondLevelDocument) | ||
|
||
assertEquals(document.get("secondLevelDocument").isDefined, true) | ||
assertEquals(document.get("secondLevelDocument.test").isEmpty, true) | ||
|
||
val v = BsonConverter.documentValueOption(Document(document.toJson()), "secondLevelDocument.test") | ||
assertEquals(v.isDefined, true) | ||
|
||
} | ||
|
||
test("evaluate get with dot notation") { | ||
val document: mutable.Document = mutable.Document() | ||
val secondLevelDocument = mutable.Document() | ||
secondLevelDocument.put("test", 42) | ||
document.put("secondLevelDocument", secondLevelDocument) | ||
|
||
assertEquals(document.get("secondLevelDocument").isDefined, true) | ||
assertEquals(document.get("secondLevelDocument.test"), None) | ||
|
||
val v = BsonConverter.documentValueOption(Document(document.toJson()), "secondLevelDocument.test") | ||
|
||
assertEquals(v.isDefined, true) | ||
} | ||
|
||
test("evaluate put with dot notation") { | ||
val document = Document() | ||
|
||
var updated: Document = BsonConverter.updateDocumentValue(document, "test", 42) | ||
|
||
assertEquals(updated.getIntValue("test"), 42) | ||
|
||
updated = BsonConverter.updateDocumentValue(document, "test.test.test.test", 42) | ||
|
||
assertEquals(updated.getIntValue("test.test.test.test"), 42) | ||
} | ||
|
||
} |
34 changes: 0 additions & 34 deletions
34
src/test/scala/dev/mongocamp/driver/mongodb/bson/ConverterSpec.scala
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
src/test/scala/dev/mongocamp/driver/mongodb/bson/ConverterSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package dev.mongocamp.driver.mongodb.bson | ||
|
||
import dev.mongocamp.driver.mongodb.Converter | ||
import dev.mongocamp.driver.mongodb.model.Base | ||
|
||
class ConverterSuite extends munit.FunSuite { | ||
|
||
test("Converter support Document roundtrip") { | ||
val base = Base() | ||
val document = Converter.toDocument(base) | ||
val integer: Int = document.getInteger("int") | ||
val long: Long = document.getLong("Long") | ||
val float : Float = document.getDouble("float").floatValue() | ||
val double : Double = document.getDouble("double") | ||
val maybeBsonValue = document.get("option") | ||
|
||
assertEquals(integer, base.int) | ||
assertEquals(long, base.Long) | ||
assertEquals(float, base.float) | ||
assertEquals(double, base.double) | ||
assertEquals(document.getString("string"), base.string) | ||
assertEquals(document.getDate("date"), base.date) | ||
assertEquals(maybeBsonValue.isDefined, true) | ||
assertEquals(maybeBsonValue.get.asObjectId().getValue, base.option.get) | ||
assertEquals(base != null, true) | ||
assertEquals(base.isInstanceOf[Base], true) | ||
} | ||
|
||
} |
Oops, something went wrong.