Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions test/unit/dialects/better-sqlite3.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';
const path = require('path');
const expect = require('chai').expect;
const fs = require('fs');
const knex = require('../../../knex');

describe('better-sqlite3 unit tests', () => {
Expand Down Expand Up @@ -50,12 +51,19 @@ describe('better-sqlite3 unit tests', () => {
});

describe('readonly', () => {
const dbPath = path.resolve(__dirname, '../test.sqlite3');

before(() => {
// Read-only access requires the DB file to exist.
fs.writeFileSync(dbPath, '');
});

it('should initialize the DB with the passed-in `readonly` option', async () => {
const knexInstance = knex({
client: 'better-sqlite3',
useNullAsDefault: true,
connection: {
filename: __dirname + '/../test.sqlite3',
filename: dbPath,
options: {
readonly: true,
},
Expand All @@ -71,7 +79,7 @@ describe('better-sqlite3 unit tests', () => {
client: 'better-sqlite3',
useNullAsDefault: true,
connection: {
filename: __dirname + '/../test.sqlite3',
filename: dbPath,
options: {
readonly: true,
},
Expand All @@ -88,7 +96,7 @@ describe('better-sqlite3 unit tests', () => {
client: 'better-sqlite3',
useNullAsDefault: true,
connection: {
filename: __dirname + '/../test.sqlite3',
filename: dbPath,
},
});

Expand Down