Skip to content
This repository was archived by the owner on Sep 2, 2024. It is now read-only.

Cleanup database provider tests #124

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant