update to new sdk
This commit is contained in:
@@ -45,6 +45,15 @@ export default class FileSystemAdapter extends BaseNotesAdapter {
|
|||||||
await fs.unlink(filePath)
|
await fs.unlink(filePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async testConnection() {
|
||||||
|
try {
|
||||||
|
await fs.access(this.notesDir)
|
||||||
|
return true
|
||||||
|
} catch (error) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async _write(note) {
|
async _write(note) {
|
||||||
const filePath = path.join(this.notesDir, `${note.id}.json`)
|
const filePath = path.join(this.notesDir, `${note.id}.json`)
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { describe, it } from 'vitest'
|
import { describe, it } from 'vitest'
|
||||||
import { runPluginTests } from '@takerofnotes/plugin-sdk'
|
import { describePluginTests } from '@takerofnotes/plugin-sdk'
|
||||||
import plugin from './src/index.js'
|
import plugin from './src/index.js'
|
||||||
import FileSystemAdapter from './src/FileSystemAdapter.js'
|
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { fileURLToPath } from 'url'
|
import { fileURLToPath } from 'url'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
@@ -13,33 +12,6 @@ if (!fs.existsSync(testDir)) {
|
|||||||
fs.mkdirSync(testDir, { recursive: true })
|
fs.mkdirSync(testDir, { recursive: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
const adapter = new FileSystemAdapter({ notesDir: testDir })
|
const adapter = plugin.createAdapter({ notesDir: testDir })
|
||||||
const tests = runPluginTests({ plugin, adapter })
|
|
||||||
|
|
||||||
describe('Plugin Validation', () => {
|
describePluginTests({ plugin, adapter }, describe, it, expect)
|
||||||
tests.validatePlugin(it, (a, b) => expect(a).toBe(b))
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('Adapter: init()', () => {
|
|
||||||
tests.init(it)
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('Adapter: getAll()', () => {
|
|
||||||
tests.getAll(it)
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('Adapter: create()', () => {
|
|
||||||
tests.create(it)
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('Adapter: update()', () => {
|
|
||||||
tests.update(it)
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('Adapter: delete()', () => {
|
|
||||||
tests.delete(it)
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('Full CRUD Cycle', () => {
|
|
||||||
tests.crudCycle(it)
|
|
||||||
})
|
|
||||||
|
|||||||
@@ -3,5 +3,6 @@ import { defineConfig } from 'vitest/config'
|
|||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
test: {
|
test: {
|
||||||
globals: true,
|
globals: true,
|
||||||
|
testTimeout: 30000,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user