1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- package backend
- import (
- "context"
- "kpt-tmr-group/config"
- "kpt-tmr-group/store/kptstore"
- "kpt-tmr-group/test/mock"
- "golang.org/x/sync/errgroup"
- "github.com/golang/mock/gomock"
- "github.com/stretchr/testify/suite"
- "go.uber.org/dig"
- )
- var dbName = "kpt_tmr_group_test"
- type Suite struct {
- suite.Suite
- ctx context.Context
- cfg *config.AppConfig
- db *kptstore.DB
- ctrl *gomock.Controller
- m Mock
- storeEntry *StoreEntry
- }
- type Mock struct {
- dig.In
- }
- func (s *Suite) SetupSuite() {
- s.cfg = config.Options()
- }
- func (s *Suite) SetupTest() {
- s.ctx = context.Background()
- s.ctrl = gomock.NewController(s.T())
- mock.GetMock(s.ctrl, func(m Mock) { s.m = m })
- s.storeEntry = NewStoreEntry(s.cfg, s.db)
- }
- func (s *Suite) prepareDB() {
- s.cfg = config.Options()
- g, _ := errgroup.WithContext(context.Background())
- g.Go(func() error { // todo 连接数据库
- return nil
- })
- if err := g.Wait(); err != nil {
- panic(err)
- }
- }
|