-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated interfaces according to stdext/sql
- Loading branch information
1 parent
3966391
commit e5f2ac6
Showing
11 changed files
with
282 additions
and
210 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
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 |
---|---|---|
@@ -1,11 +1,28 @@ | ||
import { SqliteConnection } from "./connection.ts"; | ||
import { connectionConstructorTest } from "@halvardm/sqlx/testing"; | ||
import { assert, assertEquals } from "@std/assert"; | ||
import { SqliteConnectable, SqliteConnection } from "./connection.ts"; | ||
import { _testSqlConnectable, testSqlConnection } from "@stdext/sql/testing"; | ||
|
||
Deno.test("Connection", async (t) => { | ||
await connectionConstructorTest({ | ||
t, | ||
Connection: SqliteConnection, | ||
connectionUrl: ":memory:", | ||
connectionOptions: {}, | ||
}); | ||
Deno.test("connection and connectable contstructs", () => { | ||
const connection = new SqliteConnection(":memory:"); | ||
testSqlConnection(connection, { connectionUrl: ":memory:" }); | ||
const connectable = new SqliteConnectable(connection); | ||
_testSqlConnectable(connectable, connection); | ||
}); | ||
|
||
Deno.test("connection can connect and query", async () => { | ||
await using connection = new SqliteConnection(":memory:"); | ||
await connection.connect(); | ||
assert(connection.connected, "connection should be connected"); | ||
const executeResult = await connection.execute(`select 1 as one`); | ||
assertEquals(executeResult, 0); | ||
const queryManyResult = connection.queryMany(`select 1 as one`); | ||
const queryManyResultNext1 = await queryManyResult.next(); | ||
assertEquals(queryManyResultNext1, { done: false, value: { one: 1 } }); | ||
const queryManyResultNext2 = await queryManyResult.next(); | ||
assertEquals(queryManyResultNext2, { done: true, value: undefined }); | ||
const queryManyArrayResult = connection.queryManyArray(`select 1 as one`); | ||
const queryManyArrayResultNext1 = await queryManyArrayResult.next(); | ||
assertEquals(queryManyArrayResultNext1, { done: false, value: [1] }); | ||
const queryManyArrayResultNext2 = await queryManyArrayResult.next(); | ||
assertEquals(queryManyArrayResultNext2, { done: true, value: undefined }); | ||
}); |
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
Oops, something went wrong.