-
-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
88 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
export * from "./file"; | ||
export * from "./SQLiteMetadataStore"; | ||
export { | ||
PrismaClient, | ||
prisma as dendronPrisma, | ||
} from "../generated-prisma-client"; |
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
13 changes: 13 additions & 0 deletions
13
...s/engine-test-utils/src/__tests__/engine-server/drivers/__snapshots__/sqlite.spec.ts.snap
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`GIVEN sqlite store WHEN initialize, THEN metadata has all notes 1`] = ` | ||
Array [ | ||
"dendron.code-workspace", | ||
"dendron.yml", | ||
"hooks", | ||
"metadata.db", | ||
"vault1", | ||
"vault2", | ||
"vault3", | ||
] | ||
`; |
26 changes: 26 additions & 0 deletions
26
packages/engine-test-utils/src/__tests__/engine-server/drivers/sqlite.spec.ts
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { ENGINE_HOOKS, runEngineTestV5 } from "../../.."; | ||
import fs from "fs-extra"; | ||
import { SQLiteMetadataStore } from "@dendronhq/engine-server"; | ||
import _ from "lodash"; | ||
|
||
describe("GIVEN sqlite store", () => { | ||
test("WHEN initialize, THEN metadata has all notes", async () => { | ||
await runEngineTestV5( | ||
async ({ wsRoot, engine }) => { | ||
const dirList = fs.readdirSync(wsRoot); | ||
expect(dirList).toMatchSnapshot(); | ||
expect(dirList.includes("metadata.db")).toBeTruthy(); | ||
const notes = await SQLiteMetadataStore.prisma().notes.findMany(); | ||
expect(_.size(engine.notes)).toEqual(notes.length); | ||
}, | ||
{ | ||
expect, | ||
preSetupHook: ENGINE_HOOKS.setupBasic, | ||
modConfigCb: (config) => { | ||
config.workspace.metadataStore = "sqlite"; | ||
return config; | ||
}, | ||
} | ||
); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { PrismaClient } from "@prisma/client"; | ||
import { mockDeep, mockReset, DeepMockProxy } from "jest-mock-extended"; | ||
import { dendronPrisma } from "@dendronhq/engine-server"; | ||
|
||
jest.mock("./client", () => ({ | ||
__esModule: true, | ||
default: mockDeep<PrismaClient>(), | ||
})); | ||
|
||
beforeEach(() => { | ||
mockReset(prismaMock); | ||
}); | ||
|
||
export const prismaMock = | ||
dendronPrisma as unknown as DeepMockProxy<PrismaClient>; |
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