🤡 Use uber mock for mocks
This commit is contained in:
parent
c73dfc0d3a
commit
ecae0d5f83
11 changed files with 2306 additions and 144 deletions
|
|
@ -3,16 +3,23 @@ package store
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"codeberg.org/danjones000/combluotion/config"
|
||||
"codeberg.org/danjones000/combluotion/internal/testmocks"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go.uber.org/mock/gomock"
|
||||
|
||||
"codeberg.org/danjones000/combluotion/config"
|
||||
storeMock "codeberg.org/danjones000/combluotion/internal/testmocks/store"
|
||||
)
|
||||
|
||||
var f StoreFactory = func(config.Config) (Store, error) {
|
||||
return testmocks.GetStore(), nil
|
||||
func getStoreFactory(t *testing.T) (*gomock.Controller, StoreFactory) {
|
||||
t.Helper()
|
||||
ctrl := gomock.NewController(t)
|
||||
return ctrl, func(config.Config) (Store, error) {
|
||||
return storeMock.NewMockStore(ctrl), nil
|
||||
}
|
||||
}
|
||||
|
||||
func TestAddFactory(t *testing.T) {
|
||||
_, f := getStoreFactory(t)
|
||||
AddFactory("mock", f)
|
||||
defer delete(factories, "mock")
|
||||
_, ok := factories["mock"]
|
||||
|
|
@ -25,9 +32,10 @@ func TestGetFactoryNil(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetFactoryNotNil(t *testing.T) {
|
||||
_, f := getStoreFactory(t)
|
||||
AddFactory("mock", f)
|
||||
defer delete(factories, "mock")
|
||||
f := GetFactory("mock")
|
||||
f = GetFactory("mock")
|
||||
assert.NotNil(t, f)
|
||||
}
|
||||
|
||||
|
|
@ -39,6 +47,7 @@ func TestMakeStoreError(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestMakeStoreNoError(t *testing.T) {
|
||||
_, f := getStoreFactory(t)
|
||||
AddFactory("mock", f)
|
||||
defer delete(factories, "mock")
|
||||
s, e := MakeStore("mock", config.Config{})
|
||||
|
|
@ -47,6 +56,7 @@ func TestMakeStoreNoError(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestMakeStoreNoName(t *testing.T) {
|
||||
_, f := getStoreFactory(t)
|
||||
AddFactory("mock", f)
|
||||
defer delete(factories, "mock")
|
||||
s, e := MakeStore("", config.Config{
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import (
|
|||
"github.com/openshift/osin"
|
||||
)
|
||||
|
||||
//go:generate mockgen -source store.go -destination ../internal/testmocks/store/store_mock.go -package store -typed
|
||||
|
||||
type ClientSaver interface {
|
||||
// UpdateClient updates the client (identified by it's id) and replaces the values with the values of client.
|
||||
UpdateClient(c osin.Client) error
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue