Skip to content

Instantly share code, notes, and snippets.

@frekw
Created September 26, 2017 07:48
Show Gist options
  • Save frekw/a7ddf0a2e1cc7fb8ae8bc51426563700 to your computer and use it in GitHub Desktop.
Save frekw/a7ddf0a2e1cc7fb8ae8bc51426563700 to your computer and use it in GitHub Desktop.
def comment do
gen all id <- positive_integer(),
author <- string(:alphanumeric, max_length: 64),
body <- string(:alphanumeric) do
%{id: id,
author: author,
body: body}
end
end
def stats(comments) do
# how do generate this properties based on
# data in "comments" properly?
ids = map(comments, &(&1.id))
gen all deleted <- positive_integer(),
in_review <- list_of(ids),
flagged <- list_of(ids) do
%{deleted: deleted,
in_review: in_review,
flagged: flagged}
end
end
def post do
gen all body <- string(:alphanumeric)
author <- string(:alphanumeric, max_length: 64)
comments <- list_of(comment())
stats <- stats(comments) do
%{author: author,
body: body,
comments: comments,
stats: stats}
end
end
Add Comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment