(source: FumaDb)
| 123 | // disarmed test. |
| 124 | const failPluginStorageBulkWriteAfterFirstRow = (db: FumaDb): FumaDb => { |
| 125 | const wrap = (source: FumaDb): FumaDb => |
| 126 | new Proxy(source, { |
| 127 | get(target, property, receiver) { |
| 128 | if (property === "withContext") { |
| 129 | const withContext = target.withContext; |
| 130 | return withContext === undefined |
| 131 | ? undefined |
| 132 | : (context: unknown) => wrap(withContext(context)); |
| 133 | } |
| 134 | if (property === "transaction") { |
| 135 | const transaction: FumaDb["transaction"] = (run) => |
| 136 | target.transaction((transactionDb) => run(wrap(transactionDb))); |
| 137 | return transaction; |
| 138 | } |
| 139 | if (property === "upsertMany") { |
| 140 | const upsertMany: FumaDb["upsertMany"] = async (table, options) => { |
| 141 | if (table !== "plugin_storage" || options.values.length < 2) { |
| 142 | return target.upsertMany(table, options); |
| 143 | } |
| 144 | |
| 145 | await target.upsertMany(table, { |
| 146 | ...options, |
| 147 | values: options.values.slice(0, 1), |
| 148 | }); |
| 149 | // oxlint-disable-next-line executor/no-promise-reject -- boundary: fault-injecting FumaDB adapter must reject to exercise transaction rollback |
| 150 | return Promise.reject( |
| 151 | new StorageError({ |
| 152 | message: "Injected plugin storage bulk-write failure.", |
| 153 | cause: undefined, |
| 154 | }), |
| 155 | ); |
| 156 | }; |
| 157 | return upsertMany; |
| 158 | } |
| 159 | return Reflect.get(target, property, receiver); |
| 160 | }, |
| 161 | }); |
| 162 | |
| 163 | return wrap(db); |
| 164 | }; |
no outgoing calls
no test coverage detected