Remove unnecessary connection chain step
This commit is contained in:
@@ -34,17 +34,13 @@ type MenuStorageService struct {
|
||||
userDataStore db.Db
|
||||
}
|
||||
|
||||
func NewMenuStorageService(resourceDir string) *MenuStorageService {
|
||||
func NewMenuStorageService(conn ConnData, resourceDir string) *MenuStorageService {
|
||||
return &MenuStorageService{
|
||||
conn: conn,
|
||||
resourceDir: resourceDir,
|
||||
}
|
||||
}
|
||||
|
||||
func (ms *MenuStorageService) WithConn(conn ConnData) *MenuStorageService {
|
||||
ms.conn = conn
|
||||
return ms
|
||||
}
|
||||
|
||||
func (ms *MenuStorageService) getOrCreateDb(ctx context.Context, existingDb db.Db, section string) (db.Db, error) {
|
||||
var newDb db.Db
|
||||
var err error
|
||||
|
||||
@@ -50,13 +50,7 @@ func TestEngine(sessionId string) (engine.Engine, func(), chan bool) {
|
||||
os.Exit(1)
|
||||
}
|
||||
resourceDir := scriptDir
|
||||
menuStorageService := storage.NewMenuStorageService(resourceDir)
|
||||
|
||||
menuStorageService.WithConn(conn)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "conn error: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
menuStorageService := storage.NewMenuStorageService(conn, resourceDir)
|
||||
|
||||
rs, err := menuStorageService.GetResource(ctx)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user