/
test.js
40 lines (35 loc) · 955 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"use strict";
const fastify = require("fastify")();
const fs = require("fs");
const tap = require("tap");
const Sequelize = require("sequelize-cockroachdb");
const fastifyCockroach = require("./index");
// This test suite recreates https://www.cockroachlabs.com/docs/stable/build-a-nodejs-app-with-cockroachdb-sequelize.html
tap.test("fastify.cockroachdb should exist", test => {
test.plan(3);
fastify.register(fastifyCockroach, {
database: "bank",
user: "maxroach",
models: [
{
name: "accounts",
alias: "Account",
schema: {
id: {
type: Sequelize.INTEGER,
primaryKey: true
},
balance: {
type: Sequelize.INTEGER
}
}
}
]
});
fastify.ready(err => {
test.error(err);
test.ok(fastify.cockroachdb.instance);
test.ok(fastify.cockroachdb.models.Account);
fastify.close(() => test.end());
});
});