Using data sources in simulations
(Enterprise customers only) Hoverfly Cloud supports the use of CSV data sources so that you can do key value data lookups and simulate persistence within your simulations.
Last updated
(Enterprise customers only) Hoverfly Cloud supports the use of CSV data sources so that you can do key value data lookups and simulate persistence within your simulations.
Last updated
You can upload a csv file when editing your simulation from the Simulation tab.
You can both query data from a CSV data source as well as manipulate data within a data source by adding to it and deleting from it. Hoverfly supports a number of templating methods for simple read, update and delete functions. In addition Hoverfly supports a templating function that allows simple SQL like commands for SELECT, UPDATE and DELETE.
Note that you cannot edit the data sources on a simulation already running on a service. You need to add and remove data sources from the master copy of the simulation, and then start a service running a copy of that simulation.
To use the data in the csv file, you need to use the {{ csv }} templating function.
So for example given a data source named "products" with the following csv structure:
You can use the following syntax to render the word "shirt" in a response template (note the use of single quotes):
Or if for example the productId was provided at position 1 on the path:
Or if you needed to loop over some JSON array of productIds from the request body and render back data doing lookups for each productId:
There are a number of functions to allow querying, updating, deleting and inserting data into the csv data sources. You can read more about them below:
Querying csv data sources
Updating csv data sources
Deleting data from csv data sources
Inserting data into csv data sources
Guidance on using the SQL like syntax