Use sarafu-api module
This commit is contained in:
parent
5f261c642d
commit
210d75b3f4
@ -18,12 +18,13 @@ import (
|
||||
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/config"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/initializers"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/remote"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/common"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/session"
|
||||
|
||||
at "git.grassecon.net/grassrootseconomics/visedriver-africastalking/africastalking"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver-africastalking/args"
|
||||
|
||||
httpremote "git.grassecon.net/grassrootseconomics/sarafu-api/remote/http"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
|
||||
)
|
||||
|
||||
@ -132,8 +133,8 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
accountService := remote.AccountService{}
|
||||
hl, err := lhs.GetHandler(&accountService)
|
||||
accountService := &httpremote.HTTPAccountService{}
|
||||
hl, err := lhs.GetHandler(accountService)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, err.Error())
|
||||
os.Exit(1)
|
||||
|
@ -18,8 +18,8 @@ import (
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/initializers"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/session"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/remote"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/request"
|
||||
httpremote "git.grassecon.net/grassrootseconomics/sarafu-api/remote/http"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/args"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
|
||||
)
|
||||
@ -131,9 +131,9 @@ func main() {
|
||||
|
||||
lhs, err := handlers.NewLocalHandlerService(ctx, pfp, true, dbResource, cfg, rs)
|
||||
lhs.SetDataStore(&userdataStore)
|
||||
accountService := remote.AccountService{}
|
||||
accountService := &httpremote.HTTPAccountService{}
|
||||
|
||||
hl, err := lhs.GetHandler(&accountService)
|
||||
hl, err := lhs.GetHandler(accountService)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, err.Error())
|
||||
os.Exit(1)
|
||||
|
@ -21,8 +21,8 @@ import (
|
||||
httpsession "git.grassecon.net/grassrootseconomics/visedriver/session/http"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/session"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/remote"
|
||||
|
||||
httpremote "git.grassecon.net/grassrootseconomics/sarafu-api/remote/http"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/args"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
|
||||
)
|
||||
@ -121,8 +121,8 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
accountService := remote.AccountService{}
|
||||
hl, err := lhs.GetHandler(&accountService)
|
||||
accountService := &httpremote.HTTPAccountService{}
|
||||
hl, err := lhs.GetHandler(accountService)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, err.Error())
|
||||
os.Exit(1)
|
||||
|
@ -13,8 +13,8 @@ import (
|
||||
"git.defalsify.org/vise.git/lang"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/config"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/initializers"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/remote"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/common"
|
||||
httpremote "git.grassecon.net/grassrootseconomics/sarafu-api/remote/http"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/args"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
|
||||
)
|
||||
@ -131,8 +131,8 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
accountService := remote.AccountService{}
|
||||
hl, err := lhs.GetHandler(&accountService)
|
||||
accountService := &httpremote.HTTPAccountService{}
|
||||
hl, err := lhs.GetHandler(accountService)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, err.Error())
|
||||
os.Exit(1)
|
||||
|
1
go.mod
1
go.mod
@ -4,6 +4,7 @@ go 1.23.4
|
||||
|
||||
require (
|
||||
git.defalsify.org/vise.git v0.2.3-0.20250103172917-3e190a44568d
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250111175819-d3e6a462aa0f
|
||||
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250111151614-46bf21b7b8bd
|
||||
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250111150203-fd8301144509
|
||||
github.com/alecthomas/assert/v2 v2.2.2
|
||||
|
2
go.sum
2
go.sum
@ -1,5 +1,7 @@
|
||||
git.defalsify.org/vise.git v0.2.3-0.20250103172917-3e190a44568d h1:bPAOVZOX4frSGhfOdcj7kc555f8dc9DmMd2YAyC2AMw=
|
||||
git.defalsify.org/vise.git v0.2.3-0.20250103172917-3e190a44568d/go.mod h1:jyBMe1qTYUz3mmuoC9JQ/TvFeW0vTanCUcPu3H8p4Ck=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250111175819-d3e6a462aa0f h1:5WTCUeIlRNTJtdyqd1inF+F6RZ2PUcVcGg1eX9vqT1E=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250111175819-d3e6a462aa0f/go.mod h1:0cuilFAZApPE/SMa3cP72TPdH1MoqhuDEaeJ0VGQ6/I=
|
||||
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250111151614-46bf21b7b8bd h1:mKCov8udBJBQuMF3aFg38SkClL8OvAUZmtArNzgIPak=
|
||||
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250111151614-46bf21b7b8bd/go.mod h1:E6W7ZOa7ZvVr0Bc5ot0LNSwpSPYq4hXlAIvEPy3AJ7U=
|
||||
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250111150203-fd8301144509 h1:xlX2FAJkjn1/VS/1z8A9eSGnKWDUmBJy+GtEEDRmggc=
|
||||
|
@ -8,8 +8,9 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"git.defalsify.org/vise.git/asm"
|
||||
"gopkg.in/leonelquinteros/gotext.v1"
|
||||
|
||||
"git.defalsify.org/vise.git/asm"
|
||||
"git.defalsify.org/vise.git/cache"
|
||||
"git.defalsify.org/vise.git/db"
|
||||
"git.defalsify.org/vise.git/lang"
|
||||
@ -19,9 +20,9 @@ import (
|
||||
"git.defalsify.org/vise.git/state"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/common"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/utils"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/models"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/remote"
|
||||
"gopkg.in/leonelquinteros/gotext.v1"
|
||||
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-api/models"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
|
||||
|
||||
dbstorage "git.grassecon.net/grassrootseconomics/visedriver/storage/db"
|
||||
dataserviceapi "github.com/grassrootseconomics/ussd-data-service/pkg/api"
|
||||
@ -63,14 +64,14 @@ type MenuHandlers struct {
|
||||
userdataStore common.DataStore
|
||||
adminstore *utils.AdminStore
|
||||
flagManager *asm.FlagParser
|
||||
accountService remote.AccountServiceInterface
|
||||
accountService remote.AccountService
|
||||
prefixDb dbstorage.PrefixDb
|
||||
profile *models.Profile
|
||||
ReplaceSeparatorFunc func(string) string
|
||||
}
|
||||
|
||||
// NewHandlers creates a new instance of the Handlers struct with the provided dependencies.
|
||||
func NewMenuHandlers(appFlags *asm.FlagParser, userdataStore db.Db, adminstore *utils.AdminStore, accountService remote.AccountServiceInterface, replaceSeparatorFunc func(string) string) (*MenuHandlers, error) {
|
||||
func NewMenuHandlers(appFlags *asm.FlagParser, userdataStore db.Db, adminstore *utils.AdminStore, accountService remote.AccountService, replaceSeparatorFunc func(string) string) (*MenuHandlers, error) {
|
||||
if userdataStore == nil {
|
||||
return nil, fmt.Errorf("cannot create handler with nil userdata store")
|
||||
}
|
||||
|
@ -15,10 +15,10 @@ import (
|
||||
"git.defalsify.org/vise.git/resource"
|
||||
"git.defalsify.org/vise.git/state"
|
||||
dbstorage "git.grassecon.net/grassrootseconomics/visedriver/storage/db"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/testutil/mocks"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/testutil/testservice"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/utils"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/models"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-api/models"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-api/testutil/testservice"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-api/testutil/mocks"
|
||||
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/common"
|
||||
"github.com/alecthomas/assert/v2"
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
"git.defalsify.org/vise.git/resource"
|
||||
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/utils"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/remote"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/application"
|
||||
)
|
||||
|
||||
@ -64,7 +64,7 @@ func (ls *LocalHandlerService) SetDataStore(db *db.Db) {
|
||||
ls.UserdataStore = db
|
||||
}
|
||||
|
||||
func (ls *LocalHandlerService) GetHandler(accountService remote.AccountServiceInterface) (*application.MenuHandlers, error) {
|
||||
func (ls *LocalHandlerService) GetHandler(accountService remote.AccountService) (*application.MenuHandlers, error) {
|
||||
replaceSeparatorFunc := func(input string) string {
|
||||
return strings.ReplaceAll(input, ":", ls.Cfg.MenuSeparator)
|
||||
}
|
||||
|
@ -16,10 +16,8 @@ import (
|
||||
"git.defalsify.org/vise.git/logging"
|
||||
"git.defalsify.org/vise.git/resource"
|
||||
"git.defalsify.org/vise.git/state"
|
||||
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/remote"
|
||||
|
||||
httpremote "git.grassecon.net/grassrootseconomics/sarafu-api/remote/http"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
|
||||
)
|
||||
|
||||
@ -182,7 +180,7 @@ func(s *SshRunner) GetEngine(sessionId string) (engine.Engine, func(), error) {
|
||||
}
|
||||
|
||||
// TODO: clear up why pointer here and by-value other cmds
|
||||
accountService := &remote.AccountService{}
|
||||
accountService := &httpremote.HTTPAccountService{}
|
||||
hl, err := lhs.GetHandler(accountService)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
testdataloader "github.com/peteole/testdata-loader"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
"git.defalsify.org/vise.git/engine"
|
||||
"git.defalsify.org/vise.git/logging"
|
||||
@ -18,10 +19,10 @@ import (
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/config"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/testutil/testservice"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/testutil/testtag"
|
||||
testdataloader "github.com/peteole/testdata-loader"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/remote"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-api/testutil/testservice"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
|
||||
httpremote "git.grassecon.net/grassrootseconomics/sarafu-api/remote/http"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/testutil/testtag"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -168,7 +169,7 @@ func TestEngine(sessionId string) (engine.Engine, func(), chan bool) {
|
||||
}
|
||||
|
||||
if testtag.AccountService == nil {
|
||||
testtag.AccountService = &remote.AccountService{}
|
||||
testtag.AccountService = &httpremote.HTTPAccountService{}
|
||||
}
|
||||
|
||||
switch testtag.AccountService.(type) {
|
||||
@ -176,7 +177,7 @@ func TestEngine(sessionId string) (engine.Engine, func(), chan bool) {
|
||||
go func() {
|
||||
eventChannel <- false
|
||||
}()
|
||||
case *remote.AccountService:
|
||||
case remote.AccountService:
|
||||
go func() {
|
||||
time.Sleep(5 * time.Second) // Wait for 5 seconds
|
||||
eventChannel <- true
|
||||
|
12
testutil/testtag/offlinetest.go
Normal file
12
testutil/testtag/offlinetest.go
Normal file
@ -0,0 +1,12 @@
|
||||
// +build !online
|
||||
|
||||
package testtag
|
||||
|
||||
import (
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
|
||||
accountservice "git.grassecon.net/grassrootseconomics/sarafu-api/testutil/testservice"
|
||||
)
|
||||
|
||||
var (
|
||||
AccountService remote.AccountService = &accountservice.TestAccountService{}
|
||||
)
|
9
testutil/testtag/onlinetest.go
Normal file
9
testutil/testtag/onlinetest.go
Normal file
@ -0,0 +1,9 @@
|
||||
// +build online
|
||||
|
||||
package testtag
|
||||
|
||||
import "git.grassecon.net/grassrootseconomics/visedriver/remote"
|
||||
|
||||
var (
|
||||
AccountService remote.AccountServiceInterface
|
||||
)
|
Loading…
Reference in New Issue
Block a user