Skip to content

Commit 8502b70

Browse files
committed
updates tests and mocks
1 parent 0e1572e commit 8502b70

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+26355
-43
lines changed

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,19 @@ toolchain go1.24.1
77
require github.com/gorilla/mux v1.8.1
88

99
require (
10+
github.com/davecgh/go-spew v1.1.1 // indirect
1011
github.com/golang-jwt/jwt/v5 v5.2.2 // indirect
1112
github.com/google/uuid v1.6.0 // indirect
1213
github.com/jackc/pgpassfile v1.0.0 // indirect
1314
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
1415
github.com/jackc/pgx/v5 v5.7.4 // indirect
1516
github.com/jackc/puddle/v2 v2.2.2 // indirect
1617
github.com/joho/godotenv v1.5.1 // indirect
18+
github.com/pmezard/go-difflib v1.0.0 // indirect
19+
github.com/stretchr/objx v0.5.2 // indirect
20+
github.com/stretchr/testify v1.10.0 // indirect
1721
golang.org/x/crypto v0.37.0 // indirect
1822
golang.org/x/sync v0.13.0 // indirect
1923
golang.org/x/text v0.24.0 // indirect
24+
gopkg.in/yaml.v3 v3.0.1 // indirect
2025
)

go.sum

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
2+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
3+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
24
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
35
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
46
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
@@ -15,10 +17,15 @@ github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo
1517
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
1618
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
1719
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
20+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1821
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
1922
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
23+
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
24+
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
2025
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
2126
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
27+
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
28+
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
2229
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
2330
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
2431
golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE=
@@ -33,3 +40,5 @@ golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0=
3340
golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU=
3441
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
3542
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
43+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
44+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
package categories
2+
3+
import (
4+
"bullet-cloud-api/internal/models"
5+
"context"
6+
7+
"github.com/google/uuid"
8+
"github.com/stretchr/testify/mock"
9+
)
10+
11+
// MockCategoryRepository is a mock type for the CategoryRepository interface
12+
type MockCategoryRepository struct {
13+
mock.Mock
14+
}
15+
16+
// Create provides a mock function with given fields: ctx, category
17+
func (_m *MockCategoryRepository) Create(ctx context.Context, category *models.Category) (*models.Category, error) {
18+
ret := _m.Called(ctx, category)
19+
20+
var r0 *models.Category
21+
if rf, ok := ret.Get(0).(func(context.Context, *models.Category) *models.Category); ok {
22+
r0 = rf(ctx, category)
23+
} else {
24+
if ret.Get(0) != nil {
25+
r0 = ret.Get(0).(*models.Category)
26+
}
27+
}
28+
29+
var r1 error
30+
if rf, ok := ret.Get(1).(func(context.Context, *models.Category) error); ok {
31+
r1 = rf(ctx, category)
32+
} else {
33+
r1 = ret.Error(1)
34+
}
35+
36+
return r0, r1
37+
}
38+
39+
// FindByID provides a mock function with given fields: ctx, id
40+
func (_m *MockCategoryRepository) FindByID(ctx context.Context, id uuid.UUID) (*models.Category, error) {
41+
ret := _m.Called(ctx, id)
42+
43+
var r0 *models.Category
44+
if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) *models.Category); ok {
45+
r0 = rf(ctx, id)
46+
} else {
47+
if ret.Get(0) != nil {
48+
r0 = ret.Get(0).(*models.Category)
49+
}
50+
}
51+
52+
var r1 error
53+
if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok {
54+
r1 = rf(ctx, id)
55+
} else {
56+
r1 = ret.Error(1)
57+
}
58+
59+
return r0, r1
60+
}
61+
62+
// FindAll provides a mock function with given fields: ctx
63+
func (_m *MockCategoryRepository) FindAll(ctx context.Context) ([]models.Category, error) {
64+
ret := _m.Called(ctx)
65+
66+
var r0 []models.Category
67+
if rf, ok := ret.Get(0).(func(context.Context) []models.Category); ok {
68+
r0 = rf(ctx)
69+
} else {
70+
if ret.Get(0) != nil {
71+
r0 = ret.Get(0).([]models.Category)
72+
}
73+
}
74+
75+
var r1 error
76+
if rf, ok := ret.Get(1).(func(context.Context) error); ok {
77+
r1 = rf(ctx)
78+
} else {
79+
r1 = ret.Error(1)
80+
}
81+
82+
return r0, r1
83+
}
84+
85+
// Update provides a mock function with given fields: ctx, id, category
86+
func (_m *MockCategoryRepository) Update(ctx context.Context, id uuid.UUID, category *models.Category) (*models.Category, error) {
87+
ret := _m.Called(ctx, id, category)
88+
89+
var r0 *models.Category
90+
if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, *models.Category) *models.Category); ok {
91+
r0 = rf(ctx, id, category)
92+
} else {
93+
if ret.Get(0) != nil {
94+
r0 = ret.Get(0).(*models.Category)
95+
}
96+
}
97+
98+
var r1 error
99+
if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, *models.Category) error); ok {
100+
r1 = rf(ctx, id, category)
101+
} else {
102+
r1 = ret.Error(1)
103+
}
104+
105+
return r0, r1
106+
}
107+
108+
// Delete provides a mock function with given fields: ctx, id
109+
func (_m *MockCategoryRepository) Delete(ctx context.Context, id uuid.UUID) error {
110+
ret := _m.Called(ctx, id)
111+
112+
var r0 error
113+
if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) error); ok {
114+
r0 = rf(ctx, id)
115+
} else {
116+
r0 = ret.Error(0)
117+
}
118+
119+
return r0
120+
}
121+
122+
// FindByName provides a mock function with given fields: ctx, name
123+
func (_m *MockCategoryRepository) FindByName(ctx context.Context, name string) (*models.Category, error) {
124+
ret := _m.Called(ctx, name)
125+
126+
var r0 *models.Category
127+
if rf, ok := ret.Get(0).(func(context.Context, string) *models.Category); ok {
128+
r0 = rf(ctx, name)
129+
} else {
130+
if ret.Get(0) != nil {
131+
r0 = ret.Get(0).(*models.Category)
132+
}
133+
}
134+
135+
var r1 error
136+
if rf, ok := ret.Get(1).(func(context.Context, string) error); ok {
137+
r1 = rf(ctx, name)
138+
} else {
139+
r1 = ret.Error(1)
140+
}
141+
142+
return r0, r1
143+
}

0 commit comments

Comments
 (0)