> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pool.day/llms.txt
> Use this file to discover all available pages before exploring further.

# Testing

> Run the real engine in unit tests and SwiftUI previews, with no photo library, no app key and no network.

```swift theme={null}
import PoolKit
import Testing

@Test func findsTheSneaker() async throws {
    let source = FixtureSource(assets: [
        FixtureAsset(text: ["Nike Air Max 90", "€149.99", "www.nike.com/air-max-90"]),
        FixtureAsset(source: .photos, labels: ["coffee", "cup"]),
    ])
    let pool = try await PoolClient.preview(source: source)
    let grant = try await pool.authorization.requestAccess(AccessRequest(purpose: "Tests"))
    await pool.sources.indexNow()

    let result = try await pool.context.query("nike", using: grant)
    #expect(result.matches.contains { $0.entity?.label == "nike.com/air-max-90" })
    #expect(result.coverage.isComplete)
}
```

* `FixtureAsset` describes a capture by what would be read from it: lines of text, labels, barcodes, a capture date.
* `FixtureSource` stands in for the photo library. Add and remove assets, or call `setPermission` to test limited and denied access.
* `PoolClient.preview` runs the same store, policy and query engine as production, in memory.

## Test the unhappy paths

```swift theme={null}
await source.setPermission(.denied)
await #expect(throws: PoolError.permissionDenied) {
    _ = try await pool.authorization.requestAccess(AccessRequest(purpose: "Tests"))
}
```

On a device or simulator, use a `pk_test_` key. Test keys are free, never billed, and limited to 25 installs and 10,000 cloud assist units a month, enough to index a test library of a few thousand photos and try `ask`, `profile` and `classify`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.