aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarvin Borner2020-07-18 21:04:46 +0200
committerMarvin Borner2020-07-18 21:04:46 +0200
commit39254cbdaffe91c599ab268cef8999a16a0ef7f0 (patch)
tree8d51749c4a9f66a0e11157014923a00aa2b97adf
parentaf611a4eb21e998a06af79ecfa9f6898a2c7c55f (diff)
Testing works now!
-rw-r--r--test/database_test.ts31
1 files changed, 15 insertions, 16 deletions
diff --git a/test/database_test.ts b/test/database_test.ts
index 07c5443..bc5611b 100644
--- a/test/database_test.ts
+++ b/test/database_test.ts
@@ -1,5 +1,5 @@
import "https://deno.land/x/dotenv/load.ts";
-import { assertThrowsAsync } from "https://deno.land/std/testing/asserts.ts";
+import { assertThrowsAsync, assert } from "https://deno.land/std/testing/asserts.ts";
import { Client } from "https://deno.land/x/mysql/mod.ts";
import DBController from "../src/db/DBController.ts";
@@ -11,7 +11,7 @@ Deno.test("database connection", async () => {
Deno.test({
name: "database initialization",
- sanitizeOps: false, // TODO: Find async leak in controller.execute!
+ sanitizeResources: false,
async fn() {
await controller.init();
},
@@ -19,8 +19,7 @@ Deno.test({
Deno.test({
name: "database table creation",
- sanitizeOps: false, // TODO: Previous bug!
- sanitizeResources: false, // TODO: Previous bug!
+ sanitizeResources: false,
async fn() {
await controller.execute("DROP TABLE IF EXISTS test");
await controller.execute("CREATE TABLE test (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(16) UNIQUE)");
@@ -29,8 +28,7 @@ Deno.test({
Deno.test({
name: "database variable arguments",
- sanitizeOps: false, // TODO: Previous bug!
- sanitizeResources: false, // TODO: Previous bug!
+ sanitizeResources: false,
async fn() {
await controller.execute("INSERT INTO test(name) VALUES(?)", ["Melvin"]);
assertThrowsAsync(
@@ -44,8 +42,7 @@ Deno.test({
Deno.test({
name: "database multiple statements",
- sanitizeOps: false, // TODO: Previous bug!
- sanitizeResources: false, // TODO: Previous bug!
+ sanitizeResources: false,
async fn() {
await controller.execute_multiple([
["DELETE FROM test WHERE ?? = ?", ["name", "Melvin"]],
@@ -56,16 +53,18 @@ Deno.test({
Deno.test({
name: "database select statements",
- sanitizeOps: false, // TODO: Previous bug!
- sanitizeResources: false, // TODO: Previous bug!
+ sanitizeResources: false,
async fn() {
- const count = await controller.query("SELECT ?? FROM ?? WHERE gd=4", ["name", "test"]);
- // TODO: WHY DOESN'T THIS WORK?
- console.log(count);
+ const element = await controller.query("SELECT ?? FROM ?? WHERE id=?", ["name", "test", "4"]);
+ assert(element[0].name == "Melvin");
},
});
-Deno.test("database close", async () => {
- await controller.execute("DROP TABLE test");
- await controller.close(); // TODO: Fix 'Bad resource ID'!
+Deno.test({
+ name: "database select statements",
+ sanitizeResources: false,
+ async fn() {
+ await controller.execute("DROP TABLE test");
+ await controller.close();
+ },
});