FakeKarbone

class FakeKarbone(var status: ApiStatus = ApiStatus(true, HTTP_OK, "OK", "fake"), var renderer: FakeKarbone.Renderer = Renderer.Default) : KarboneClient

In-memory KarboneClient for consumer tests. No network, no Carbone.

  • Templates are stored by their SHA-256, exactly like Carbone's legacy ids; the hash-first render flow works as with the real client.

  • com.ekino.oss.karbone.Renders.render produces bytes through renderer; the default writes a small JSON description of the request, with a filename derived from reportName / convertTo.

  • Every call is recorded in calls; failNextWith injects one error on the next call.

Constructors

Link copied to clipboard
constructor(status: ApiStatus = ApiStatus(true, HTTP_OK, "OK", "fake"), renderer: FakeKarbone.Renderer = Renderer.Default)

Types

Link copied to clipboard
sealed interface Call

One call recorded in calls.

Link copied to clipboard
fun interface Renderer

Produces the bytes of a rendered document.

Link copied to clipboard
data class RenderRequest(val templateId: TemplateId, val template: ByteArray?, val data: JsonElement?, val options: RenderOptions)

A render request passed to Renderer.render.

Link copied to clipboard
data class StoredTemplate(val id: TemplateId, val content: ByteArray, val options: UploadOptions, val createdAt: Instant)

A template held in the in-memory store.

Properties

Link copied to clipboard

Every call made on this fake, in order.

Link copied to clipboard

Rendered documents recorded so far (one per render / start / startAsync).

Link copied to clipboard

Strategy used to produce rendered bytes. Defaults to Renderer.Default.

Link copied to clipboard
open override val renders: Renders

Document generation operations.

Link copied to clipboard

Value returned by status. Mutable so a test can simulate a degraded or custom status.

Link copied to clipboard

Templates currently stored.

Link copied to clipboard
open override val templates: Templates

Template upload, download, listing and metadata operations.

Functions

Link copied to clipboard
fun addTemplate(content: ByteArray, options: UploadOptions = UploadOptions()): TemplateId

Pre-load a template so TemplateSource.Remote ids resolve. Returns its id (SHA-256).

Link copied to clipboard

Blocking, exception-based view of any KarboneClient: the real com.ekino.oss.karbone.Karbone or a test double.

Link copied to clipboard

The next call, whatever it is, raises error instead of running.

Link copied to clipboard
fun reset()

Clears stored templates, recorded calls and rendered documents, and any pending failNextWith error.

Link copied to clipboard
context(_: Raise<KarboneError>)
open suspend override fun status(): ApiStatus

GET /status.