Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelDarley committed Jun 25, 2024
1 parent 1f61676 commit 21b4524
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 21 deletions.
22 changes: 12 additions & 10 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ jobs:
build: |
yarn build
strip -x *.node
- host: windows-latest
build: yarn build
target: x86_64-pc-windows-msvc
- host: windows-latest
build: |
yarn build --target i686-pc-windows-msvc
yarn build
yarn test
target: i686-pc-windows-msvc
target: x86_64-pc-windows-msvc
# - host: windows-latest
# build: |
# yarn build --target i686-pc-windows-msvc
# yarn test
# target: i686-pc-windows-msvc
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
Expand Down Expand Up @@ -78,11 +80,11 @@ jobs:
build: |
yarn build --target aarch64-linux-android
${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip *.node
- host: ubuntu-latest
target: armv7-linux-androideabi
build: |
yarn build --target armv7-linux-androideabi
${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip *.node
# - host: ubuntu-latest
# target: armv7-linux-androideabi
# build: |
# yarn build --target armv7-linux-androideabi
# ${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip *.node
- host: ubuntu-latest
target: aarch64-unknown-linux-musl
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
Expand Down
35 changes: 26 additions & 9 deletions __test__/index.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
import test from "ava";

import { Surreal } from "../index.js";
import { Surreal } from 'surrealdb.js';
import { surrealdbNodeEngines } from '../lib-src/embedded.ts';

test("Connect in-memory SurrealDB instance", async (t) => {
const db = new Surreal();
const db = new Surreal({
engines: surrealdbNodeEngines(),
});
await db.connect("memory");
t.pass();
});

test("set ns/db", async (t) => {
{
const db = new Surreal();
const db = new Surreal({
engines: surrealdbNodeEngines(),
});
await db.connect("memory");
await db.use({ namespace: "test" });
}

{
const db = new Surreal();
const db = new Surreal({
engines: surrealdbNodeEngines(),
});
await db.connect("memory");
await db.use({ database: "test" });
}

{
const db = new Surreal();
const db = new Surreal({
engines: surrealdbNodeEngines(),
});
await db.connect("memory");
await db.use({ namespace: "test", database: "test" });
}
Expand All @@ -31,7 +40,9 @@ test("set ns/db", async (t) => {
});

test("test query method", async (t) => {
const db = new Surreal();
const db = new Surreal({
engines: surrealdbNodeEngines(),
});
await db.connect("memory");
await db.use({ namespace: "test", database: "test" });

Expand All @@ -56,7 +67,9 @@ test("test query method", async (t) => {
});

test("set and and unset", async (t) => {
const db = new Surreal();
const db = new Surreal({
engines: surrealdbNodeEngines(),
});
await db.connect("memory");
await db.use({ namespace: "test", database: "test" });

Expand All @@ -77,7 +90,9 @@ test("set and and unset", async (t) => {
});

test("auth", async (t) => {
const db = new Surreal();
const db = new Surreal({
engines: surrealdbNodeEngines(),
});
await db.connect("memory");
await db.use({
namespace: "test",
Expand Down Expand Up @@ -124,7 +139,9 @@ test("auth", async (t) => {
});

test("test select method", async (t) => {
const db = new Surreal();
const db = new Surreal({
engines: surrealdbNodeEngines(),
});
await db.connect("memory");
await db.use({ namespace: "test", database: "test" });

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@
},
"scripts": {
"artifacts": "node move_artifacts.js",
"build": "napi build --platform --release",
"build": "napi build --platform --release && bash ./fix-deps.sh",
"build:debug": "napi build --platform && bash ./fix-deps.sh && yarn ts-compile",
"prepublishOnly": "napi prepublish -t npm",
"test": "ava",
"test": "npm install --global tsx && tsx tests.ts",
"universal": "napi universal",
"version": "napi version",
"ts-compile": "npm install --global typescript && tsc --version"
Expand Down
16 changes: 16 additions & 0 deletions tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Surreal from "surrealdb.js";
import { surrealdbNodeEngines } from "./lib-src/embedded.ts";

const surreal = new Surreal({
engines: surrealdbNodeEngines()
});

// console.log("connecting", await surreal.connect("mem://"));

// console.log("using", await surreal.use({ namespace: "test", database: "test" }));

// console.log("listening", await surreal.live("test", (res) => console.log("recieved live" + res)));

// console.log("creating", await surreal.create('test', { val: 42 }));

// console.log("closing", await surreal.close());

0 comments on commit 21b4524

Please sign in to comment.