pass user service to handler New function
parent
49d098346d
commit
dcac51377e
|
@ -72,30 +72,26 @@ func NewAPIHandler(b *APIBackend) *APIHandler {
|
|||
h.SessionHandler.SessionService = b.SessionService
|
||||
h.SessionHandler.Logger = b.Logger.With(zap.String("handler", "basicAuth"))
|
||||
|
||||
h.BucketHandler = NewBucketHandler(b.UserResourceMappingService, b.LabelService)
|
||||
h.BucketHandler = NewBucketHandler(b.UserResourceMappingService, b.LabelService, b.UserService)
|
||||
h.BucketHandler.BucketService = b.BucketService
|
||||
h.BucketHandler.BucketOperationLogService = b.BucketOperationLogService
|
||||
h.BucketHandler.UserService = b.UserService
|
||||
|
||||
h.OrgHandler = NewOrgHandler(b.UserResourceMappingService, b.LabelService)
|
||||
h.OrgHandler = NewOrgHandler(b.UserResourceMappingService, b.LabelService, b.UserService)
|
||||
h.OrgHandler.OrganizationService = b.OrganizationService
|
||||
h.OrgHandler.BucketService = b.BucketService
|
||||
h.OrgHandler.OrganizationOperationLogService = b.OrganizationOperationLogService
|
||||
h.OrgHandler.UserService = b.UserService
|
||||
|
||||
h.UserHandler = NewUserHandler()
|
||||
h.UserHandler.UserService = b.UserService
|
||||
h.UserHandler.BasicAuthService = b.BasicAuthService
|
||||
h.UserHandler.UserOperationLogService = b.UserOperationLogService
|
||||
|
||||
h.DashboardHandler = NewDashboardHandler(b.UserResourceMappingService, b.LabelService)
|
||||
h.DashboardHandler = NewDashboardHandler(b.UserResourceMappingService, b.LabelService, b.UserService)
|
||||
h.DashboardHandler.DashboardService = b.DashboardService
|
||||
h.DashboardHandler.DashboardOperationLogService = b.DashboardOperationLogService
|
||||
h.DashboardHandler.UserService = b.UserService
|
||||
|
||||
h.ViewHandler = NewViewHandler(b.UserResourceMappingService, b.LabelService)
|
||||
h.ViewHandler = NewViewHandler(b.UserResourceMappingService, b.LabelService, b.UserService)
|
||||
h.ViewHandler.ViewService = b.ViewService
|
||||
h.ViewHandler.UserService = b.UserService
|
||||
|
||||
h.MacroHandler = NewMacroHandler()
|
||||
h.MacroHandler.MacroService = b.MacroService
|
||||
|
@ -112,19 +108,18 @@ func NewAPIHandler(b *APIBackend) *APIHandler {
|
|||
h.SetupHandler = NewSetupHandler()
|
||||
h.SetupHandler.OnboardingService = b.OnboardingService
|
||||
|
||||
h.TaskHandler = NewTaskHandler(b.UserResourceMappingService, b.LabelService, b.Logger)
|
||||
h.TaskHandler = NewTaskHandler(b.UserResourceMappingService, b.LabelService, b.Logger, b.UserService)
|
||||
h.TaskHandler.TaskService = b.TaskService
|
||||
h.TaskHandler.AuthorizationService = b.AuthorizationService
|
||||
h.TaskHandler.UserResourceMappingService = b.UserResourceMappingService
|
||||
h.TaskHandler.UserService = b.UserService
|
||||
|
||||
h.TelegrafHandler = NewTelegrafHandler(
|
||||
b.Logger.With(zap.String("handler", "telegraf")),
|
||||
b.UserResourceMappingService,
|
||||
b.LabelService,
|
||||
b.TelegrafService,
|
||||
b.UserService,
|
||||
)
|
||||
h.TelegrafHandler.UserService = b.UserService
|
||||
|
||||
h.WriteHandler = NewWriteHandler(b.PointsWriter)
|
||||
h.WriteHandler.OrganizationService = b.OrganizationService
|
||||
|
|
|
@ -39,11 +39,12 @@ const (
|
|||
)
|
||||
|
||||
// NewBucketHandler returns a new instance of BucketHandler.
|
||||
func NewBucketHandler(mappingService platform.UserResourceMappingService, labelService platform.LabelService) *BucketHandler {
|
||||
func NewBucketHandler(mappingService platform.UserResourceMappingService, labelService platform.LabelService, userService platform.UserService) *BucketHandler {
|
||||
h := &BucketHandler{
|
||||
Router: NewRouter(),
|
||||
UserResourceMappingService: mappingService,
|
||||
LabelService: labelService,
|
||||
UserService: userService,
|
||||
}
|
||||
|
||||
h.HandlerFunc("POST", bucketsPath, h.handlePostBucket)
|
||||
|
|
|
@ -124,7 +124,8 @@ func TestService_handleGetBuckets(t *testing.T) {
|
|||
t.Run(tt.name, func(t *testing.T) {
|
||||
mappingService := mock.NewUserResourceMappingService()
|
||||
labelService := mock.NewLabelService()
|
||||
h := NewBucketHandler(mappingService, labelService)
|
||||
userService := mock.NewUserService()
|
||||
h := NewBucketHandler(mappingService, labelService, userService)
|
||||
h.BucketService = tt.fields.BucketService
|
||||
|
||||
r := httptest.NewRequest("GET", "http://any.url", nil)
|
||||
|
@ -242,7 +243,8 @@ func TestService_handleGetBucket(t *testing.T) {
|
|||
t.Run(tt.name, func(t *testing.T) {
|
||||
mappingService := mock.NewUserResourceMappingService()
|
||||
labelService := mock.NewLabelService()
|
||||
h := NewBucketHandler(mappingService, labelService)
|
||||
userService := mock.NewUserService()
|
||||
h := NewBucketHandler(mappingService, labelService, userService)
|
||||
h.BucketService = tt.fields.BucketService
|
||||
|
||||
r := httptest.NewRequest("GET", "http://any.url", nil)
|
||||
|
@ -338,7 +340,8 @@ func TestService_handlePostBucket(t *testing.T) {
|
|||
t.Run(tt.name, func(t *testing.T) {
|
||||
mappingService := mock.NewUserResourceMappingService()
|
||||
labelService := mock.NewLabelService()
|
||||
h := NewBucketHandler(mappingService, labelService)
|
||||
userService := mock.NewUserService()
|
||||
h := NewBucketHandler(mappingService, labelService, userService)
|
||||
h.BucketService = tt.fields.BucketService
|
||||
|
||||
b, err := json.Marshal(newBucket(tt.args.bucket))
|
||||
|
@ -433,7 +436,8 @@ func TestService_handleDeleteBucket(t *testing.T) {
|
|||
t.Run(tt.name, func(t *testing.T) {
|
||||
mappingService := mock.NewUserResourceMappingService()
|
||||
labelService := mock.NewLabelService()
|
||||
h := NewBucketHandler(mappingService, labelService)
|
||||
userService := mock.NewUserService()
|
||||
h := NewBucketHandler(mappingService, labelService, userService)
|
||||
h.BucketService = tt.fields.BucketService
|
||||
|
||||
r := httptest.NewRequest("GET", "http://any.url", nil)
|
||||
|
@ -708,7 +712,8 @@ func TestService_handlePatchBucket(t *testing.T) {
|
|||
t.Run(tt.name, func(t *testing.T) {
|
||||
mappingService := mock.NewUserResourceMappingService()
|
||||
labelService := mock.NewLabelService()
|
||||
h := NewBucketHandler(mappingService, labelService)
|
||||
userService := mock.NewUserService()
|
||||
h := NewBucketHandler(mappingService, labelService, userService)
|
||||
h.BucketService = tt.fields.BucketService
|
||||
|
||||
upd := platform.BucketUpdate{}
|
||||
|
@ -776,7 +781,8 @@ func initBucketService(f platformtesting.BucketFields, t *testing.T) (platform.B
|
|||
|
||||
mappingService := mock.NewUserResourceMappingService()
|
||||
labelService := mock.NewLabelService()
|
||||
handler := NewBucketHandler(mappingService, labelService)
|
||||
userService := mock.NewUserService()
|
||||
handler := NewBucketHandler(mappingService, labelService, userService)
|
||||
handler.BucketService = svc
|
||||
server := httptest.NewServer(handler)
|
||||
client := BucketService{
|
||||
|
|
|
@ -41,11 +41,12 @@ const (
|
|||
)
|
||||
|
||||
// NewDashboardHandler returns a new instance of DashboardHandler.
|
||||
func NewDashboardHandler(mappingService platform.UserResourceMappingService, labelService platform.LabelService) *DashboardHandler {
|
||||
func NewDashboardHandler(mappingService platform.UserResourceMappingService, labelService platform.LabelService, userService platform.UserService) *DashboardHandler {
|
||||
h := &DashboardHandler{
|
||||
Router: NewRouter(),
|
||||
UserResourceMappingService: mappingService,
|
||||
LabelService: labelService,
|
||||
UserService: userService,
|
||||
}
|
||||
|
||||
h.HandlerFunc("POST", dashboardsPath, h.handlePostDashboard)
|
||||
|
|
|
@ -162,7 +162,8 @@ func TestService_handleGetDashboards(t *testing.T) {
|
|||
t.Run(tt.name, func(t *testing.T) {
|
||||
mappingService := mock.NewUserResourceMappingService()
|
||||
labelService := mock.NewLabelService()
|
||||
h := NewDashboardHandler(mappingService, labelService)
|
||||
userService := mock.NewUserService()
|
||||
h := NewDashboardHandler(mappingService, labelService, userService)
|
||||
h.DashboardService = tt.fields.DashboardService
|
||||
|
||||
r := httptest.NewRequest("GET", "http://any.url", nil)
|
||||
|
@ -307,7 +308,8 @@ func TestService_handleGetDashboard(t *testing.T) {
|
|||
t.Run(tt.name, func(t *testing.T) {
|
||||
mappingService := mock.NewUserResourceMappingService()
|
||||
labelService := mock.NewLabelService()
|
||||
h := NewDashboardHandler(mappingService, labelService)
|
||||
userService := mock.NewUserService()
|
||||
h := NewDashboardHandler(mappingService, labelService, userService)
|
||||
h.DashboardService = tt.fields.DashboardService
|
||||
|
||||
r := httptest.NewRequest("GET", "http://any.url", nil)
|
||||
|
@ -435,7 +437,8 @@ func TestService_handlePostDashboard(t *testing.T) {
|
|||
t.Run(tt.name, func(t *testing.T) {
|
||||
mappingService := mock.NewUserResourceMappingService()
|
||||
labelService := mock.NewLabelService()
|
||||
h := NewDashboardHandler(mappingService, labelService)
|
||||
userService := mock.NewUserService()
|
||||
h := NewDashboardHandler(mappingService, labelService, userService)
|
||||
h.DashboardService = tt.fields.DashboardService
|
||||
|
||||
b, err := json.Marshal(tt.args.dashboard)
|
||||
|
@ -526,7 +529,8 @@ func TestService_handleDeleteDashboard(t *testing.T) {
|
|||
t.Run(tt.name, func(t *testing.T) {
|
||||
mappingService := mock.NewUserResourceMappingService()
|
||||
labelService := mock.NewLabelService()
|
||||
h := NewDashboardHandler(mappingService, labelService)
|
||||
userService := mock.NewUserService()
|
||||
h := NewDashboardHandler(mappingService, labelService, userService)
|
||||
h.DashboardService = tt.fields.DashboardService
|
||||
|
||||
r := httptest.NewRequest("GET", "http://any.url", nil)
|
||||
|
@ -697,7 +701,8 @@ func TestService_handlePatchDashboard(t *testing.T) {
|
|||
t.Run(tt.name, func(t *testing.T) {
|
||||
mappingService := mock.NewUserResourceMappingService()
|
||||
labelService := mock.NewLabelService()
|
||||
h := NewDashboardHandler(mappingService, labelService)
|
||||
userService := mock.NewUserService()
|
||||
h := NewDashboardHandler(mappingService, labelService, userService)
|
||||
h.DashboardService = tt.fields.DashboardService
|
||||
|
||||
upd := platform.DashboardUpdate{}
|
||||
|
@ -807,7 +812,8 @@ func TestService_handlePostDashboardCell(t *testing.T) {
|
|||
t.Run(tt.name, func(t *testing.T) {
|
||||
mappingService := mock.NewUserResourceMappingService()
|
||||
labelService := mock.NewLabelService()
|
||||
h := NewDashboardHandler(mappingService, labelService)
|
||||
userService := mock.NewUserService()
|
||||
h := NewDashboardHandler(mappingService, labelService, userService)
|
||||
h.DashboardService = tt.fields.DashboardService
|
||||
|
||||
b, err := json.Marshal(tt.args.cell)
|
||||
|
@ -891,7 +897,8 @@ func TestService_handleDeleteDashboardCell(t *testing.T) {
|
|||
t.Run(tt.name, func(t *testing.T) {
|
||||
mappingService := mock.NewUserResourceMappingService()
|
||||
labelService := mock.NewLabelService()
|
||||
h := NewDashboardHandler(mappingService, labelService)
|
||||
userService := mock.NewUserService()
|
||||
h := NewDashboardHandler(mappingService, labelService, userService)
|
||||
h.DashboardService = tt.fields.DashboardService
|
||||
|
||||
r := httptest.NewRequest("GET", "http://any.url", nil)
|
||||
|
@ -1006,7 +1013,8 @@ func TestService_handlePatchDashboardCell(t *testing.T) {
|
|||
t.Run(tt.name, func(t *testing.T) {
|
||||
mappingService := mock.NewUserResourceMappingService()
|
||||
labelService := mock.NewLabelService()
|
||||
h := NewDashboardHandler(mappingService, labelService)
|
||||
userService := mock.NewUserService()
|
||||
h := NewDashboardHandler(mappingService, labelService, userService)
|
||||
h.DashboardService = tt.fields.DashboardService
|
||||
|
||||
upd := platform.CellUpdate{}
|
||||
|
@ -1105,9 +1113,10 @@ func initDashboardService(f platformtesting.DashboardFields, t *testing.T) (plat
|
|||
|
||||
mappingService := mock.NewUserResourceMappingService()
|
||||
labelService := mock.NewLabelService()
|
||||
handler := NewDashboardHandler(mappingService, labelService)
|
||||
handler.DashboardService = svc
|
||||
server := httptest.NewServer(handler)
|
||||
userService := mock.NewUserService()
|
||||
h := NewDashboardHandler(mappingService, labelService, userService)
|
||||
h.DashboardService = svc
|
||||
server := httptest.NewServer(h)
|
||||
client := DashboardService{
|
||||
Addr: server.URL,
|
||||
}
|
||||
|
|
|
@ -44,11 +44,12 @@ const (
|
|||
|
||||
// NewOrgHandler returns a new instance of OrgHandler.
|
||||
func NewOrgHandler(mappingService platform.UserResourceMappingService,
|
||||
labelService platform.LabelService) *OrgHandler {
|
||||
labelService platform.LabelService, userService platform.UserService) *OrgHandler {
|
||||
h := &OrgHandler{
|
||||
Router: NewRouter(),
|
||||
UserResourceMappingService: mappingService,
|
||||
LabelService: labelService,
|
||||
UserService: userService,
|
||||
}
|
||||
|
||||
h.HandlerFunc("POST", organizationsPath, h.handlePostOrg)
|
||||
|
|
|
@ -28,7 +28,7 @@ func initOrganizationService(f platformtesting.OrganizationFields, t *testing.T)
|
|||
}
|
||||
}
|
||||
|
||||
handler := NewOrgHandler(mock.NewUserResourceMappingService(), mock.NewLabelService())
|
||||
handler := NewOrgHandler(mock.NewUserResourceMappingService(), mock.NewLabelService(), mock.NewUserService())
|
||||
handler.OrganizationService = svc
|
||||
handler.BucketService = svc
|
||||
server := httptest.NewServer(handler)
|
||||
|
@ -123,7 +123,7 @@ func TestSecretService_handleGetSecrets(t *testing.T) {
|
|||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
h := NewOrgHandler(mock.NewUserResourceMappingService(), mock.NewLabelService())
|
||||
h := NewOrgHandler(mock.NewUserResourceMappingService(), mock.NewLabelService(), mock.NewUserService())
|
||||
h.SecretService = tt.fields.SecretService
|
||||
|
||||
u := fmt.Sprintf("http://any.url/api/v2/orgs/%s/secrets", tt.args.orgID)
|
||||
|
@ -193,7 +193,7 @@ func TestSecretService_handlePatchSecrets(t *testing.T) {
|
|||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
h := NewOrgHandler(mock.NewUserResourceMappingService(), mock.NewLabelService())
|
||||
h := NewOrgHandler(mock.NewUserResourceMappingService(), mock.NewLabelService(), mock.NewUserService())
|
||||
h.SecretService = tt.fields.SecretService
|
||||
|
||||
b, err := json.Marshal(tt.args.secrets)
|
||||
|
@ -269,7 +269,7 @@ func TestSecretService_handleDeleteSecrets(t *testing.T) {
|
|||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
h := NewOrgHandler(mock.NewUserResourceMappingService(), mock.NewLabelService())
|
||||
h := NewOrgHandler(mock.NewUserResourceMappingService(), mock.NewLabelService(), mock.NewUserService())
|
||||
h.SecretService = tt.fields.SecretService
|
||||
|
||||
b, err := json.Marshal(tt.args.secrets)
|
||||
|
|
|
@ -50,13 +50,14 @@ const (
|
|||
)
|
||||
|
||||
// NewTaskHandler returns a new instance of TaskHandler.
|
||||
func NewTaskHandler(mappingService platform.UserResourceMappingService, labelService platform.LabelService, logger *zap.Logger) *TaskHandler {
|
||||
func NewTaskHandler(mappingService platform.UserResourceMappingService, labelService platform.LabelService, logger *zap.Logger, userService platform.UserService) *TaskHandler {
|
||||
h := &TaskHandler{
|
||||
logger: logger,
|
||||
Router: NewRouter(),
|
||||
|
||||
UserResourceMappingService: mappingService,
|
||||
LabelService: labelService,
|
||||
UserService: userService,
|
||||
}
|
||||
|
||||
h.HandlerFunc("GET", tasksPath, h.handleGetTasks)
|
||||
|
|
|
@ -112,7 +112,7 @@ func TestTaskHandler_handleGetTasks(t *testing.T) {
|
|||
r := httptest.NewRequest("GET", "http://any.url", nil)
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
h := NewTaskHandler(mock.NewUserResourceMappingService(), mock.NewLabelService(), logger.New(os.Stdout))
|
||||
h := NewTaskHandler(mock.NewUserResourceMappingService(), mock.NewLabelService(), logger.New(os.Stdout), mock.NewUserService())
|
||||
h.TaskService = tt.fields.taskService
|
||||
h.handleGetTasks(w, r)
|
||||
|
||||
|
@ -212,7 +212,7 @@ func TestTaskHandler_handlePostTasks(t *testing.T) {
|
|||
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
h := NewTaskHandler(mock.NewUserResourceMappingService(), mock.NewLabelService(), logger.New(os.Stdout))
|
||||
h := NewTaskHandler(mock.NewUserResourceMappingService(), mock.NewLabelService(), logger.New(os.Stdout), mock.NewUserService())
|
||||
h.TaskService = tt.fields.taskService
|
||||
h.handlePostTask(w, r)
|
||||
|
||||
|
@ -316,7 +316,7 @@ func TestTaskHandler_handleGetRun(t *testing.T) {
|
|||
},
|
||||
}))
|
||||
w := httptest.NewRecorder()
|
||||
h := NewTaskHandler(mock.NewUserResourceMappingService(), mock.NewLabelService(), logger.New(os.Stdout))
|
||||
h := NewTaskHandler(mock.NewUserResourceMappingService(), mock.NewLabelService(), logger.New(os.Stdout), mock.NewUserService())
|
||||
h.TaskService = tt.fields.taskService
|
||||
h.handleGetRun(w, r)
|
||||
|
||||
|
@ -424,7 +424,7 @@ func TestTaskHandler_handleGetRuns(t *testing.T) {
|
|||
},
|
||||
}))
|
||||
w := httptest.NewRecorder()
|
||||
h := NewTaskHandler(mock.NewUserResourceMappingService(), mock.NewLabelService(), logger.New(os.Stdout))
|
||||
h := NewTaskHandler(mock.NewUserResourceMappingService(), mock.NewLabelService(), logger.New(os.Stdout), mock.NewUserService())
|
||||
h.TaskService = tt.fields.taskService
|
||||
h.handleGetRuns(w, r)
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ func httpTaskServiceFactory(t *testing.T) (*servicetest.System, context.CancelFu
|
|||
|
||||
h := http.NewAuthenticationHandler()
|
||||
h.AuthorizationService = i
|
||||
th := http.NewTaskHandler(mock.NewUserResourceMappingService(), mock.NewLabelService(), zaptest.NewLogger(t))
|
||||
th := http.NewTaskHandler(mock.NewUserResourceMappingService(), mock.NewLabelService(), zaptest.NewLogger(t), mock.NewUserService())
|
||||
th.TaskService = backingTS
|
||||
th.AuthorizationService = i
|
||||
h.Handler = th
|
||||
|
|
|
@ -43,6 +43,7 @@ func NewTelegrafHandler(
|
|||
mappingService platform.UserResourceMappingService,
|
||||
labelService platform.LabelService,
|
||||
telegrafSvc platform.TelegrafConfigStore,
|
||||
userService platform.UserService,
|
||||
) *TelegrafHandler {
|
||||
h := &TelegrafHandler{
|
||||
Router: NewRouter(),
|
||||
|
@ -51,6 +52,7 @@ func NewTelegrafHandler(
|
|||
LabelService: labelService,
|
||||
TelegrafService: telegrafSvc,
|
||||
Logger: logger,
|
||||
UserService: userService,
|
||||
}
|
||||
h.HandlerFunc("POST", telegrafsPath, h.handlePostTelegraf)
|
||||
h.HandlerFunc("GET", telegrafsPath, h.handleGetTelegrafs)
|
||||
|
|
|
@ -33,11 +33,12 @@ const (
|
|||
)
|
||||
|
||||
// NewViewHandler returns a new instance of ViewHandler.
|
||||
func NewViewHandler(mappingService platform.UserResourceMappingService, labelService platform.LabelService) *ViewHandler {
|
||||
func NewViewHandler(mappingService platform.UserResourceMappingService, labelService platform.LabelService, userService platform.UserService) *ViewHandler {
|
||||
h := &ViewHandler{
|
||||
Router: NewRouter(),
|
||||
UserResourceMappingService: mappingService,
|
||||
LabelService: labelService,
|
||||
UserService: userService,
|
||||
}
|
||||
|
||||
h.HandlerFunc("POST", viewsPath, h.handlePostViews)
|
||||
|
|
|
@ -129,7 +129,7 @@ func TestService_handleGetViews(t *testing.T) {
|
|||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
h := NewViewHandler(mock.NewUserResourceMappingService(), mock.NewLabelService())
|
||||
h := NewViewHandler(mock.NewUserResourceMappingService(), mock.NewLabelService(), mock.NewUserService())
|
||||
h.ViewService = tt.fields.ViewService
|
||||
|
||||
r := httptest.NewRequest("GET", "http://any.url", nil)
|
||||
|
@ -237,7 +237,7 @@ func TestService_handleGetView(t *testing.T) {
|
|||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
h := NewViewHandler(mock.NewUserResourceMappingService(), mock.NewLabelService())
|
||||
h := NewViewHandler(mock.NewUserResourceMappingService(), mock.NewLabelService(), mock.NewUserService())
|
||||
h.ViewService = tt.fields.ViewService
|
||||
|
||||
r := httptest.NewRequest("GET", "http://any.url", nil)
|
||||
|
@ -342,7 +342,7 @@ func TestService_handlePostViews(t *testing.T) {
|
|||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
h := NewViewHandler(mock.NewUserResourceMappingService(), mock.NewLabelService())
|
||||
h := NewViewHandler(mock.NewUserResourceMappingService(), mock.NewLabelService(), mock.NewUserService())
|
||||
h.ViewService = tt.fields.ViewService
|
||||
|
||||
b, err := json.Marshal(tt.args.view)
|
||||
|
@ -431,7 +431,7 @@ func TestService_handleDeleteView(t *testing.T) {
|
|||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
h := NewViewHandler(mock.NewUserResourceMappingService(), mock.NewLabelService())
|
||||
h := NewViewHandler(mock.NewUserResourceMappingService(), mock.NewLabelService(), mock.NewUserService())
|
||||
h.ViewService = tt.fields.ViewService
|
||||
|
||||
r := httptest.NewRequest("GET", "http://any.url", nil)
|
||||
|
@ -587,7 +587,7 @@ func TestService_handlePatchView(t *testing.T) {
|
|||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
h := NewViewHandler(mock.NewUserResourceMappingService(), mock.NewLabelService())
|
||||
h := NewViewHandler(mock.NewUserResourceMappingService(), mock.NewLabelService(), mock.NewUserService())
|
||||
h.ViewService = tt.fields.ViewService
|
||||
|
||||
upd := platform.ViewUpdate{}
|
||||
|
|
|
@ -8,6 +8,21 @@ import (
|
|||
|
||||
var _ platform.UserService = &UserService{}
|
||||
|
||||
// NewUserService returns a mock of NewUserService
|
||||
// where its methods will return zero values.
|
||||
func NewUserService() *UserService {
|
||||
return &UserService{
|
||||
FindUserByIDFn: func(context.Context, platform.ID) (*platform.User, error) { return nil, nil },
|
||||
FindUserFn: func(context.Context, platform.UserFilter) (*platform.User, error) { return nil, nil },
|
||||
CreateUserFn: func(context.Context, *platform.User) error { return nil },
|
||||
UpdateUserFn: func(context.Context, platform.ID, platform.UserUpdate) (*platform.User, error) { return nil, nil },
|
||||
DeleteUserFn: func(context.Context, platform.ID) error { return nil },
|
||||
FindUsersFn: func(context.Context, platform.UserFilter, ...platform.FindOptions) ([]*platform.User, int, error) {
|
||||
return nil, 0, nil
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
type UserService struct {
|
||||
FindUserByIDFn func(context.Context, platform.ID) (*platform.User, error)
|
||||
FindUserFn func(context.Context, platform.UserFilter) (*platform.User, error)
|
||||
|
|
Loading…
Reference in New Issue