✨ Improve Store
Still need to fill out SQLite bootstrap Also setup plug-in system mechanism
This commit is contained in:
parent
c4513aa94b
commit
e7b88bcc09
10 changed files with 154 additions and 6 deletions
47
store/factory_test.go
Normal file
47
store/factory_test.go
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
package store
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"codeberg.org/danjones000/lenore/config"
|
||||
"codeberg.org/danjones000/lenore/internal/testmocks"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
var f StoreFactory = func(config.Config) (Store, error) {
|
||||
return testmocks.GetStore(), nil
|
||||
}
|
||||
|
||||
func TestAddFactory(t *testing.T) {
|
||||
AddFactory("mock", f)
|
||||
defer delete(factories, "mock")
|
||||
_, ok := factories["mock"]
|
||||
assert.True(t, ok)
|
||||
}
|
||||
|
||||
func TestGetFactoryNil(t *testing.T) {
|
||||
f := GetFactory("mock")
|
||||
assert.Nil(t, f)
|
||||
}
|
||||
|
||||
func TestGetFactoryNotNil(t *testing.T) {
|
||||
AddFactory("mock", f)
|
||||
defer delete(factories, "mock")
|
||||
f := GetFactory("mock")
|
||||
assert.NotNil(t, f)
|
||||
}
|
||||
|
||||
func TestMakeStoreError(t *testing.T) {
|
||||
s, e := MakeStore("mock", config.Config{})
|
||||
assert.Nil(t, s)
|
||||
assert.ErrorIs(t, e, ErrNoFactory)
|
||||
assert.ErrorContains(t, e, ErrNoFactory.Error()+": mock")
|
||||
}
|
||||
|
||||
func TestMakeStoreNoError(t *testing.T) {
|
||||
AddFactory("mock", f)
|
||||
defer delete(factories, "mock")
|
||||
s, e := MakeStore("mock", config.Config{})
|
||||
assert.NotNil(t, s)
|
||||
assert.NoError(t, e)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue