core
core copied to clipboard
Cleanup database provider tests
Hi. I'm opening this to initiate a discussion on #80. By introducing a common dbtest package, you could drastically reduce the amount of code required in the *_test.go files.
For example:
package memory
import (
"testing"
"github.com/staticbackendhq/core/database/dbtest"
)
func TestFindToken(t *testing.T) {
dbtest.FindToken(t, datastore, adminToken)
}
func TestFindRootToken(t *testing.T) {
dbtest.FindRootToken(t, datastore, adminToken)
}
func TestGetRootForBase(t *testing.T) {
dbtest.GetRootForBase(t, datastore, adminToken)
}
func TestFindTokenByEmail(t *testing.T) {
dbtest.FindTokenByEmail(t, datastore, adminToken)
}
func TestUserEmailExists(t *testing.T) {
dbtest.UserEmailExists(t, datastore)
}
func TestAccountList(t *testing.T) {
dbtest.AccountList(t, datastore)
}
If you like this approach, I'd be happy to apply this for all database provider tests. This will likely reduce the duplicated code with about 30-40%.