Zusatzspeicher: Plus sofort anteilig, Minus zum Monatsende, Aufgaben für konsoleH
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
887e1e54a0
commit
379cc26dcd
11 files changed
+1531
-27
No files matched your search
@@ -5,8 +5,9 @@ import http from 'node:http'
|
||||
* Speicher. Mit schema = { collection: ['attr', ...] } lehnt er unbekannte Attribute ab wie
|
||||
* Appwrite ("Invalid document structure: Unknown attribute"). Dokument-IDs prüft er wie Appwrite
|
||||
* (höchstens 36 Zeichen aus a-z, A-Z, 0-9, Punkt, Bindestrich, Unterstrich, kein Sonderzeichen am
|
||||
* Anfang). failNext({ collection?, method?, status, message? }) lässt die nächste passende Anfrage
|
||||
* mit diesem Status scheitern (Fehlerpfade wie "Appwrite nicht erreichbar" oder "Collection fehlt").
|
||||
* Anfang). failNext({ collection?, method?, status, message?, after? }) lässt die nächste passende Anfrage
|
||||
* mit diesem Status scheitern (Fehlerpfade wie "Appwrite nicht erreichbar" oder "Collection fehlt");
|
||||
* after = Zahl passender Anfragen, die vorher noch durchgehen (z. B. erst die zweite PATCH scheitert).
|
||||
*/
|
||||
export async function startAppwriteMock({ schema = {} } = {}) {
|
||||
const collections = new Map()
|
||||
@@ -104,9 +105,13 @@ export async function startAppwriteMock({ schema = {} } = {}) {
|
||||
(!pendingFailure.collection || pendingFailure.collection === collection) &&
|
||||
(!pendingFailure.method || pendingFailure.method === req.method)
|
||||
) {
|
||||
const { status, message } = pendingFailure
|
||||
pendingFailure = null
|
||||
return [status, { message: message || `Nachbau: eingeplanter Fehler ${status}`, code: status, type: 'general_server_error' }]
|
||||
if (pendingFailure.after > 0) {
|
||||
pendingFailure.after -= 1
|
||||
} else {
|
||||
const { status, message } = pendingFailure
|
||||
pendingFailure = null
|
||||
return [status, { message: message || `Nachbau: eingeplanter Fehler ${status}`, code: status, type: 'general_server_error' }]
|
||||
}
|
||||
}
|
||||
|
||||
if (!id && req.method === 'GET') return list(collection, url.searchParams.getAll('queries[]'))
|
||||
@@ -155,9 +160,9 @@ export async function startAppwriteMock({ schema = {} } = {}) {
|
||||
url: `http://127.0.0.1:${server.address().port}/v1`,
|
||||
docs: (collection) => new Map([...docs(collection)].map(([id, doc]) => [id, publicDoc(doc)])),
|
||||
seed,
|
||||
/** Naechste passende Dokument-Anfrage scheitert mit status (einmalig). */
|
||||
failNext: ({ collection = null, method = null, status = 500, message = '' }) => {
|
||||
pendingFailure = { collection, method, status, message }
|
||||
/** Naechste passende Dokument-Anfrage scheitert mit status (einmalig); after passende Anfragen gehen vorher durch. */
|
||||
failNext: ({ collection = null, method = null, status = 500, message = '', after = 0 }) => {
|
||||
pendingFailure = { collection, method, status, message, after }
|
||||
},
|
||||
close: () => new Promise((resolve) => server.close(resolve)),
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user