upd(system): update public service for testing
This commit is contained in:
parent
b9ecc5e50f
commit
74e220308c
@ -4,8 +4,10 @@ import (
|
||||
"github.com/crusttech/crust/system/internal/service"
|
||||
)
|
||||
|
||||
func Init() {
|
||||
service.Init()
|
||||
func Init() error {
|
||||
err := service.Init()
|
||||
DefaultRole = service.DefaultRole
|
||||
DefaultRules = service.DefaultRules
|
||||
DefaultUser = service.DefaultUser
|
||||
return err
|
||||
}
|
||||
|
||||
27
system/service/role.go
Normal file
27
system/service/role.go
Normal file
@ -0,0 +1,27 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/crusttech/crust/system/internal/service"
|
||||
"github.com/crusttech/crust/system/types"
|
||||
)
|
||||
|
||||
type (
|
||||
RoleService interface {
|
||||
FindByID(roleID uint64) (*types.Role, error)
|
||||
Find(filter *types.RoleFilter) ([]*types.Role, error)
|
||||
}
|
||||
)
|
||||
|
||||
var DefaultRole = service.DefaultRole
|
||||
|
||||
func Role(ctx context.Context) RoleService {
|
||||
return DefaultRole.With(ctx)
|
||||
}
|
||||
|
||||
// Expose the full Role API for testing
|
||||
func TestRole(_ *testing.T, ctx context.Context) service.RoleService {
|
||||
return DefaultRole.With(ctx)
|
||||
}
|
||||
@ -2,6 +2,7 @@ package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/crusttech/crust/internal/rules"
|
||||
"github.com/crusttech/crust/system/internal/service"
|
||||
@ -18,6 +19,11 @@ type (
|
||||
|
||||
var DefaultRules = service.DefaultRules
|
||||
|
||||
func Rules(ctx context.Context) service.RulesService {
|
||||
func Rules(ctx context.Context) RulesService {
|
||||
return DefaultRules.With(ctx)
|
||||
}
|
||||
|
||||
// Expose the full Rules API for testing
|
||||
func TestRules(_ *testing.T, ctx context.Context) service.RulesService {
|
||||
return DefaultRules.With(ctx)
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/crusttech/crust/system/internal/service"
|
||||
"github.com/crusttech/crust/system/types"
|
||||
@ -22,3 +23,8 @@ var DefaultUser = service.DefaultUser
|
||||
func User(ctx context.Context) UserService {
|
||||
return DefaultUser.With(ctx)
|
||||
}
|
||||
|
||||
// Expose the full User API for testing
|
||||
func TestUser(_ *testing.T, ctx context.Context) service.UserService {
|
||||
return DefaultUser.With(ctx)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user