Docs / ArchitectureKit 2.0 / Guides / Testing Queries
Testing Queries
A query needs no test package of its own, since a test can call the function that answers it directly.
To test a query, call the function that answers it directly, with a view filled by a projection:
books, err := listBooks(catalog)(context.TODO(), ListBooks{OnlyAvailable: true})
if err != nil {
// ...
}
To test the queries of an HTTP API without a database, create the API without a store, with nil. It answers queries, and answers a command with 500 Internal Server Error, and logs that the API has no store:
api := httpapi.NewAPI(nil, userFrom)