Skip to Main Content
Property-Based Testing with PropEr, Erlang, and Elixir
book

Property-Based Testing with PropEr, Erlang, and Elixir

by Fred Hebert
January 2019
Intermediate to advanced content levelIntermediate to advanced
376 pages
8h 49m
English
Pragmatic Bookshelf
Content preview from Property-Based Testing with PropEr, Erlang, and Elixir

Case Study: Bookstore

Introducing the Application

Script to initialize the database:

 Elixir code/Bookstore/elixir/bookstore/lib/bookstore/init.ex
 defmodule​ Bookstore.Init ​do
 def​ main(_) ​do
 # See: https://www.postgresql.org/docs/9.6/static/server-start.html
  File.mkdir_p!(​"​​postgres/data/"​)
  stdout = IO.stream(​:stdio​, ​:line​)
 
  IO.puts(​"​​initializing database structure..."​)
  System.cmd(​"​​initdb"​, [​"​​-D"​, ​"​​postgres/data"​], ​into:​ stdout)
  IO.puts(​"​​starting postgres instance..."​)
 
  args = [​"​​-D"​, ​"​​postgres/data"​, ​"​​-l"​, ​"​​logfile"​, ​"​​start"​]
 case​ ​:os​.type() ​do
  {​:win32​, _} ->
  spawn(​fn​ -> System.cmd(​"​​pg_ctl"​, args, ​into:​ stdout) ​end​)
  {​:unix​, _} ->
  System.cmd(​ ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Erlang and OTP in Action

Erlang and OTP in Action

Eric Merritt, Richard Carlsson, Martin Logan
Testing Elixir

Testing Elixir

Andrea Leopardi, Jeffrey Matthias

Publisher Resources

ISBN: 9781680506556Errata Page