From 49add85c937ff42129b153feabd449d3751f13e3 Mon Sep 17 00:00:00 2001 From: Christoph Becker Date: Sat, 23 Dec 2023 12:35:59 +0100 Subject: [PATCH] chore: remove unused code --- handlers/create_test.go | 8 -------- handlers/mocks_test.go | 19 ------------------- handlers/replace_test.go | 1 - types/model.go | 18 ------------------ types/service.go | 6 ------ 5 files changed, 52 deletions(-) delete mode 100644 types/model.go diff --git a/handlers/create_test.go b/handlers/create_test.go index a4b7b65..dfc5b99 100644 --- a/handlers/create_test.go +++ b/handlers/create_test.go @@ -21,14 +21,6 @@ func (p parseDtoFromRequestServiceMock) ParseDtoFromRequest(_ *http.Request) (ty return p.dto, p.err } -type createEmptyModelServiceMock struct { - emptyModel types.Model -} - -func (c createEmptyModelServiceMock) CreateEmptyModel(_ context.Context) types.Model { - return c.emptyModel -} - type createModelServiceMock struct { createdModel testModel err error diff --git a/handlers/mocks_test.go b/handlers/mocks_test.go index df85a4b..5ae76ea 100644 --- a/handlers/mocks_test.go +++ b/handlers/mocks_test.go @@ -53,25 +53,6 @@ func (u updateModelServiceMock) UpdateModel(_ context.Context, _ testModel) (tes return u.model, u.err } -type modelMock struct { - value string - createResult modelErrorHolder[types.Model] - updateResult modelErrorHolder[types.Model] - deleteResult error -} - -func (m modelMock) Create(_ context.Context) (types.Model, error) { - return m.createResult.model, m.createResult.err -} - -func (m modelMock) Update(_ context.Context) (types.Model, error) { - return m.updateResult.model, m.updateResult.err -} - -func (m modelMock) Delete(_ context.Context) error { - return m.deleteResult -} - type errorWriterRecorder struct { called bool err error diff --git a/handlers/replace_test.go b/handlers/replace_test.go index 16480f1..5346ea8 100644 --- a/handlers/replace_test.go +++ b/handlers/replace_test.go @@ -11,7 +11,6 @@ import ( type replaceServiceMock struct { getOneServiceMock updateModelServiceMock - createEmptyModelServiceMock parseDtoFromRequestServiceMock } diff --git a/types/model.go b/types/model.go deleted file mode 100644 index 0aed031..0000000 --- a/types/model.go +++ /dev/null @@ -1,18 +0,0 @@ -package types - -import "context" - -// Model is the representation of one data Type that is managed by your api. -type Model interface { - // Create is used to persist a new instance of that model. - // It returns the created model and an error if it fails otherwise nil. - Create(ctx context.Context) (Model, error) - - // Update is used to persist new the values of an existing model. - // It returns the updated model and an error if it fails otherwise nil. - Update(ctx context.Context) (Model, error) - - // Delete deletes it self from the persisted records. - // It returns an error if it fails otherwise it returns nil. - Delete(ctx context.Context) error -} diff --git a/types/service.go b/types/service.go index 39ffa76..90c168e 100644 --- a/types/service.go +++ b/types/service.go @@ -19,12 +19,6 @@ type GetAllService[M ModelTypeInterface] interface { GetAll(request *http.Request) ([]M, error) } -// CreateEmptyModelService defines the CreateEmptyModel function that is used in multiple handlers. -type CreateEmptyModelService interface { - // CreateEmptyModel returns an empty instance of the model - CreateEmptyModel(ctx context.Context) Model -} - type CreateModelService[M ModelTypeInterface] interface { CreateModel(ctx context.Context, model M) (M, error) }