Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maartenvanvliet/glide
Library to help generating test data using StreamData
https://github.com/maartenvanvliet/glide
Last synced: 28 days ago
JSON representation
Library to help generating test data using StreamData
- Host: GitHub
- URL: https://github.com/maartenvanvliet/glide
- Owner: maartenvanvliet
- License: mit
- Created: 2021-06-12T18:47:52.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-03T05:00:34.000Z (almost 2 years ago)
- Last Synced: 2024-04-23T22:09:57.514Z (8 months ago)
- Language: Elixir
- Size: 36.1 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Glide
## [![Hex pm](http://img.shields.io/hexpm/v/glide.svg?style=flat)](https://hex.pm/packages/glide) [![Hex Docs](https://img.shields.io/badge/hex-docs-9768d1.svg)](https://hexdocs.pm/glide) [![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)![.github/workflows/elixir.yml](https://github.com/maartenvanvliet/glide/workflows/.github/workflows/elixir.yml/badge.svg)
Library to help generating test data using StreamData.
It adds several generators for commonly used values and some convenience wrappers for StreamData, allowing you to generate test data for your tests. The test data is reproducible, i.e. it will use the same seed ExUnit uses, so you'll get the same data if you supply the same seed.
The generators can be used as a stepping stone for property based tests at a later stage.
## Installation
The package can be installed by adding `glide` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:glide, "~> 0.9.0"}
]
end
```## Usage
In your tests you can either import or alias Glide depending on your preference
With import syntax it will look like
```elixir
import Glidegen(:uuid) # creates generator
val(:uuid) # builds val from generator
gen(:uuid) |> val() # builds val from generator
```If you want to use an alias:
```elixir
alias Glide, as: GG.gen(:uuid) # creates generator
G.val(:uuid) # builds val from generator
G.gen(:uuid) |> G.val() # builds val from generator
```Instead of the wrapper functions, you can also use StreamData directly for more control.
```elixir
StreamData.integer() |> G.val
```### Examples
Create fixed map, with optional subtitle
```elixir
gen(:fixed_map, %{post_id: gen(:uuid), subtitle: optional(gen(:string, [:ascii]))})
```