(opts = {})
| 172 | } |
| 173 | |
| 174 | complete(opts = {}) { |
| 175 | const id = opts.contractId || this.activeId(); |
| 176 | if (!id) throw new Error('no active contract'); |
| 177 | const c = this.get(id); |
| 178 | if (!c) throw new Error(`contract missing: ${id}`); |
| 179 | if (!c.isDone()) { |
| 180 | const status = c.doneStatus(); |
| 181 | throw new Error( |
| 182 | `cannot complete: ${status.pending} pending, ${status.failed} failed. ` + |
| 183 | `blockers: ${status.blockers.map((b) => b.id).join(', ')}`, |
| 184 | ); |
| 185 | } |
| 186 | c.status = STATUSES.COMPLETED; |
| 187 | this.save(c); |
| 188 | this._log(c.id, 'complete', {}); |
| 189 | return c; |
| 190 | } |
| 191 | |
| 192 | _log(id, event, data) { |
| 193 | try { |
no test coverage detected