Skip to content

Conversation

@mbezhanov
Copy link

@mbezhanov mbezhanov commented Jun 20, 2024

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%.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant