implement and test sql db accessor

This commit is contained in:
2024-08-27 19:27:52 -05:00
parent e6947e714d
commit fe06a95c98
24 changed files with 745 additions and 403 deletions

View File

@@ -2,7 +2,7 @@ package nkode
import (
"github.com/stretchr/testify/assert"
m "go-nkode/core/model"
"go-nkode/core/model"
"testing"
)
@@ -14,16 +14,16 @@ func TestCustomer(t *testing.T) {
func testNewCustomerAttributes(t *testing.T) {
// keypad := m.KeypadDimension{AttrsPerKey: 10, NumbOfKeys: 5}
_, nil := NewCustomerAttributes()
_, nil := m.NewCustomerAttributes()
assert.NoError(t, nil)
}
func testCustomerValidKeyEntry(t *testing.T) {
kp := m.KeypadDimension{AttrsPerKey: 10, NumbOfKeys: 9}
nkodePolicy := m.NewDefaultNKodePolicy()
customer, err := NewCustomer(nkodePolicy)
customer, err := m.NewCustomer(nkodePolicy)
assert.NoError(t, err)
newUserInterface, err := NewUserInterface(&kp)
newUserInterface, err := m.NewUserInterface(&kp)
assert.NoError(t, err)
username := m.Username("testing123")
passcodeIdx := []int{0, 1, 2, 3}
@@ -31,7 +31,7 @@ func testCustomerValidKeyEntry(t *testing.T) {
assert.NoError(t, err)
userLoginInterface, err := user.GetLoginInterface()
assert.NoError(t, err)
selectedKeys, err := SelectKeyByAttrIdx(userLoginInterface, passcodeIdx, kp)
selectedKeys, err := m.SelectKeyByAttrIdx(userLoginInterface, passcodeIdx, kp)
assert.NoError(t, err)
validatedPasscode, err := ValidKeyEntry(*user, *customer, selectedKeys)
assert.NoError(t, err)
@@ -44,9 +44,9 @@ func testCustomerValidKeyEntry(t *testing.T) {
func testCustomerIsValidNKode(t *testing.T) {
kp := m.KeypadDimension{AttrsPerKey: 10, NumbOfKeys: 7}
nkodePolicy := m.NewDefaultNKodePolicy()
customer, err := NewCustomer(nkodePolicy)
customer, err := m.NewCustomer(nkodePolicy)
assert.NoError(t, err)
newUserInterface, err := NewUserInterface(&kp)
newUserInterface, err := m.NewUserInterface(&kp)
assert.NoError(t, err)
username := m.Username("testing123")
passcodeIdx := []int{0, 1, 2, 3}