mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
feat(server): make server storage adapters (#7902)
This commit is contained in:
@@ -9,7 +9,7 @@ import request from 'supertest';
|
||||
import { AppModule } from '../../src/app.module';
|
||||
import { CurrentUser } from '../../src/core/auth';
|
||||
import { AuthService } from '../../src/core/auth/service';
|
||||
import { DocHistoryManager, DocManager } from '../../src/core/doc';
|
||||
import { PgWorkspaceDocStorageAdapter } from '../../src/core/doc';
|
||||
import { WorkspaceBlobStorage } from '../../src/core/storage';
|
||||
import { createTestingApp, internalSignIn } from '../utils';
|
||||
|
||||
@@ -18,19 +18,17 @@ const test = ava as TestFn<{
|
||||
db: PrismaClient;
|
||||
app: INestApplication;
|
||||
storage: Sinon.SinonStubbedInstance<WorkspaceBlobStorage>;
|
||||
doc: Sinon.SinonStubbedInstance<DocManager>;
|
||||
workspace: Sinon.SinonStubbedInstance<PgWorkspaceDocStorageAdapter>;
|
||||
}>;
|
||||
|
||||
test.beforeEach(async t => {
|
||||
test.before(async t => {
|
||||
const { app } = await createTestingApp({
|
||||
imports: [AppModule],
|
||||
tapModule: m => {
|
||||
m.overrideProvider(WorkspaceBlobStorage)
|
||||
.useValue(Sinon.createStubInstance(WorkspaceBlobStorage))
|
||||
.overrideProvider(DocManager)
|
||||
.useValue(Sinon.createStubInstance(DocManager))
|
||||
.overrideProvider(DocHistoryManager)
|
||||
.useValue(Sinon.createStubInstance(DocHistoryManager));
|
||||
.overrideProvider(PgWorkspaceDocStorageAdapter)
|
||||
.useValue(Sinon.createStubInstance(PgWorkspaceDocStorageAdapter));
|
||||
},
|
||||
});
|
||||
|
||||
@@ -41,7 +39,7 @@ test.beforeEach(async t => {
|
||||
t.context.db = db;
|
||||
t.context.app = app;
|
||||
t.context.storage = app.get(WorkspaceBlobStorage);
|
||||
t.context.doc = app.get(DocManager);
|
||||
t.context.workspace = app.get(PgWorkspaceDocStorageAdapter);
|
||||
|
||||
await db.workspacePage.create({
|
||||
data: {
|
||||
@@ -83,7 +81,7 @@ test.beforeEach(async t => {
|
||||
});
|
||||
});
|
||||
|
||||
test.afterEach.always(async t => {
|
||||
test.after.always(async t => {
|
||||
await t.context.app.close();
|
||||
});
|
||||
|
||||
@@ -227,10 +225,12 @@ test('should not be able to get private workspace with private page', async t =>
|
||||
});
|
||||
|
||||
test('should be able to get doc', async t => {
|
||||
const { app, doc } = t.context;
|
||||
const { app, workspace: doc } = t.context;
|
||||
|
||||
doc.getBinary.resolves({
|
||||
binary: Buffer.from([0, 0]),
|
||||
doc.getDoc.resolves({
|
||||
spaceId: '',
|
||||
docId: '',
|
||||
bin: Buffer.from([0, 0]),
|
||||
timestamp: Date.now(),
|
||||
});
|
||||
|
||||
@@ -244,10 +244,12 @@ test('should be able to get doc', async t => {
|
||||
});
|
||||
|
||||
test('should be able to change page publish mode', async t => {
|
||||
const { app, doc, db } = t.context;
|
||||
const { app, workspace: doc, db } = t.context;
|
||||
|
||||
doc.getBinary.resolves({
|
||||
binary: Buffer.from([0, 0]),
|
||||
doc.getDoc.resolves({
|
||||
spaceId: '',
|
||||
docId: '',
|
||||
bin: Buffer.from([0, 0]),
|
||||
timestamp: Date.now(),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user