Skip to content

Instantly share code, notes, and snippets.

@d6y
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d6y/9d41a8f2182b953a2e51 to your computer and use it in GitHub Desktop.
Save d6y/9d41a8f2182b953a2e51 to your computer and use it in GitHub Desktop.
populate
implicit val pc = PopulationControl(
dataSource=postgressDs,
...customzation here)
"Friends database" should {
populate("""
# User
You can document data set between table name and the table itself.
Note that _ in a cell means "I don't care, create any value you want or auto increment if it's
that kind of a column".
id | name | age |
-----+--------+------+
_ | Alice | NULL |
2 | Bob | _ |
_ | ${f()} | _ |
...and 9 others
# Friend
You can refer to foreign keys using table.column=match syntax
You'd probably not mention the id column as you don't care what goes in it.
If you don't mention a column that exist in the database, you'll get an
auto incrementing value, null or a random value depending on what we know about the column.
id | friend_er | friend_ee |
-----+---------------+-----------------+
_ | User.name=Bob | User.name=Alice |
""")
"Recognize Bob & Alice as buddies" in {
// Using whatever test and query framework you want...
friend.all.filter(_.friend_er === "Bob").map(friend_ee) must beSome("Alice")
user.count must_== 12
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment