From b5bd054bbe1ef0192fbe675e7cd55a2706f45ff7 Mon Sep 17 00:00:00 2001 From: Miguel de la Cruz Date: Mon, 10 Jul 2023 13:43:59 +0200 Subject: [PATCH] Move mocks to their own packages --- notification/{ => mocks}/service_mock.go | 4 ++-- notification/service.go | 2 +- server/helpers_test.go | 10 ++++++---- server/{ => mocks}/worker_mock.go | 4 ++-- server/worker.go | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-) rename notification/{ => mocks}/service_mock.go (95%) rename server/{ => mocks}/worker_mock.go (95%) diff --git a/notification/service_mock.go b/notification/mocks/service_mock.go similarity index 95% rename from notification/service_mock.go rename to notification/mocks/service_mock.go index 42712f7..8700f33 100644 --- a/notification/service_mock.go +++ b/notification/mocks/service_mock.go @@ -1,8 +1,8 @@ // Code generated by MockGen. DO NOT EDIT. // Source: service.go -// Package notification is a generated GoMock package. -package notification +// Package mocks is a generated GoMock package. +package mocks import ( reflect "reflect" diff --git a/notification/service.go b/notification/service.go index 4feadf5..debedef 100644 --- a/notification/service.go +++ b/notification/service.go @@ -1,4 +1,4 @@ -//go:generate mockgen -source=service.go -destination=service_mock.go -package=notification +//go:generate mockgen -source=service.go -destination=mocks/service_mock.go -package=mocks package notification import ( diff --git a/server/helpers_test.go b/server/helpers_test.go index bdbcc42..0fb7bd7 100644 --- a/server/helpers_test.go +++ b/server/helpers_test.go @@ -7,6 +7,8 @@ import ( "git.ctrlz.es/mgdelacroix/birthdaybot/model" "git.ctrlz.es/mgdelacroix/birthdaybot/notification" + notification_mocks "git.ctrlz.es/mgdelacroix/birthdaybot/notification/mocks" + server_mocks "git.ctrlz.es/mgdelacroix/birthdaybot/server/mocks" "github.com/charmbracelet/log" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" @@ -15,8 +17,8 @@ import ( type TestHelper struct { t *testing.T ctrl *gomock.Controller - mockNotificationService *notification.MockNotificationService - mockWorker *MockWorker + mockNotificationService *notification_mocks.MockNotificationService + mockWorker *server_mocks.MockWorker srv *Server } @@ -33,10 +35,10 @@ func SetupTestHelper(t *testing.T) *TestHelper { th := &TestHelper{t: t} th.ctrl = gomock.NewController(t) - th.mockNotificationService = notification.NewMockNotificationService(th.ctrl) + th.mockNotificationService = notification_mocks.NewMockNotificationService(th.ctrl) notificationServices := []notification.NotificationService{th.mockNotificationService} - th.mockWorker = NewMockWorker(th.ctrl) + th.mockWorker = server_mocks.NewMockWorker(th.ctrl) workers := []Worker{th.mockWorker} th.mockWorker.EXPECT().Start().Times(1) th.mockWorker.EXPECT().Stop().Times(1) diff --git a/server/worker_mock.go b/server/mocks/worker_mock.go similarity index 95% rename from server/worker_mock.go rename to server/mocks/worker_mock.go index b86ba02..649f99d 100644 --- a/server/worker_mock.go +++ b/server/mocks/worker_mock.go @@ -1,8 +1,8 @@ // Code generated by MockGen. DO NOT EDIT. // Source: worker.go -// Package server is a generated GoMock package. -package server +// Package mocks is a generated GoMock package. +package mocks import ( reflect "reflect" diff --git a/server/worker.go b/server/worker.go index d9f03a8..40caf4f 100644 --- a/server/worker.go +++ b/server/worker.go @@ -1,4 +1,4 @@ -//go:generate mockgen -source=worker.go -destination=worker_mock.go -package=server +//go:generate mockgen -source=worker.go -destination=mocks/worker_mock.go -package=mocks package server import (