godog/examples/db
2015-07-03 10:44:25 +03:00
..
api.go update examples/db to pass golint 2015-07-03 10:44:25 +03:00
api_test.go add a database interaction example 2015-07-02 16:18:04 +03:00
db.sql add a database interaction example 2015-07-02 16:18:04 +03:00
Makefile add a database interaction example 2015-07-02 16:18:04 +03:00
README.md add a database interaction example 2015-07-02 16:18:04 +03:00
txdb.go add a database interaction example 2015-07-02 16:18:04 +03:00
users.feature add a database interaction example 2015-07-02 16:18:04 +03:00

An example of API with DB

The following example demonstrates steps how we describe and test our API with DB using godog. To start with, see API example before. We have extended it to be used with database.

The interesting point is, that we have txdb.go which has an implementation of custom sql.driver to allow execute every and each scenario within a transaction. After it completes, transaction is rolled back so the state could be clean for the next scenario.

To run users.feature you need MySQL installed on your system with an anonymous root password. Then run:

make test

The json comparisom function should be improved and we should also have placeholders for primary keys when comparing a json result.