package
0.0.0-20230512090756-d0b8ee358d97
Repository: https://github.com/protogodev/dbtest.git
Documentation: pkg.go.dev

# README

User Store

This example illustrates how to apply declarative testing for a typical database application.

Prerequisites

  1. Prepare the database

    Execute the SQLs in user.sql:

    $ mysql -uroot -p -e 'source ./user.sql'
    
  2. Implement the testee factory

    See NewTestee().

  3. Write the test specification

    See dbtest.spec.yaml.

Generate tests

$ go generate

See store_test.go for generated tests.

Run tests

$ go test -v -race
Result
=== RUN   TestCreateUser
=== RUN   TestCreateUser/new_user
=== RUN   TestCreateUser/duplicate_user
--- PASS: TestCreateUser (0.05s)
    --- PASS: TestCreateUser/new_user (0.01s)
    --- PASS: TestCreateUser/duplicate_user (0.02s)
=== RUN   TestGetUser
=== RUN   TestGetUser/ok
=== RUN   TestGetUser/not_found
--- PASS: TestGetUser (0.02s)
    --- PASS: TestGetUser/ok (0.00s)
    --- PASS: TestGetUser/not_found (0.01s)
=== RUN   TestUpdateUser
=== RUN   TestUpdateUser/ok
=== RUN   TestUpdateUser/not_found
--- PASS: TestUpdateUser (0.04s)
    --- PASS: TestUpdateUser/ok (0.02s)
    --- PASS: TestUpdateUser/not_found (0.02s)
=== RUN   TestDeleteUser
=== RUN   TestDeleteUser/ok
=== RUN   TestDeleteUser/not_found
--- PASS: TestDeleteUser (0.04s)
    --- PASS: TestDeleteUser/ok (0.01s)
    --- PASS: TestDeleteUser/not_found (0.02s)
PASS
ok      github.com/RussellLuo/dbtest/examples   0.175s

# Functions

No description provided by the author
NewTestee creates a testee for use in tests that are not in this package.

# Structs

No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author