mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-21 09:46:40 +00:00
[management] Add tests for networks managers (#3049)
This commit is contained in:
@@ -2,6 +2,7 @@ package users
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/netbirdio/netbird/management/server/store"
|
||||
"github.com/netbirdio/netbird/management/server/types"
|
||||
@@ -15,6 +16,9 @@ type managerImpl struct {
|
||||
store store.Store
|
||||
}
|
||||
|
||||
type managerMock struct {
|
||||
}
|
||||
|
||||
func NewManager(store store.Store) Manager {
|
||||
return &managerImpl{
|
||||
store: store,
|
||||
@@ -24,3 +28,22 @@ func NewManager(store store.Store) Manager {
|
||||
func (m *managerImpl) GetUser(ctx context.Context, userID string) (*types.User, error) {
|
||||
return m.store.GetUserByUserID(ctx, store.LockingStrengthShare, userID)
|
||||
}
|
||||
|
||||
func NewManagerMock() Manager {
|
||||
return &managerMock{}
|
||||
}
|
||||
|
||||
func (m *managerMock) GetUser(ctx context.Context, userID string) (*types.User, error) {
|
||||
switch userID {
|
||||
case "adminUser":
|
||||
return &types.User{Id: userID, Role: types.UserRoleAdmin}, nil
|
||||
case "regularUser":
|
||||
return &types.User{Id: userID, Role: types.UserRoleUser}, nil
|
||||
case "ownerUser":
|
||||
return &types.User{Id: userID, Role: types.UserRoleOwner}, nil
|
||||
case "billingUser":
|
||||
return &types.User{Id: userID, Role: types.UserRoleBillingAdmin}, nil
|
||||
default:
|
||||
return nil, errors.New("user not found")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user