Skip to content

Commit

Permalink
Merge pull request #19 from MidraLab/feat/mockhandler-install
Browse files Browse the repository at this point in the history
mockhandler追加
  • Loading branch information
eiei114 authored Nov 4, 2023
2 parents 6181295 + 4297497 commit c1067b3
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 24 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/auto_mockgen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:

generate:
runs-on: ubuntu-latest
env:
EXAMPLE_TESTS_ROOT: ${{ github.workspace }}
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -22,7 +24,9 @@ jobs:
go-version: 1.21.1

- name: Install mockgen
run: go install go.uber.org/mock/mockgen@latest
run: |
go install go.uber.org/mock/mockgen@latest
go install github.com/sanposhiho/gomockhandler@latest
- name: Generate mocks
run: |
Expand Down
2 changes: 1 addition & 1 deletion app/application/middleware/auth_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package middleware

import "github.com/uptrace/bunrouter"

//go:generate mockgen -source=auth_interface.go -destination=../../mocks/auth_mocks.go -package=mocks
//go:generate gomockhandler -config=$EXAMPLE_TESTS_ROOT/gomockhandler.json -source=$GOFILE -destination=mock_$GOPACKAGE/mock_$GOFILE -package=mock_$GOPACKAGE
type MiddlewareInterface interface {
AuthenticateMiddleware() func(bunrouter.HandlerFunc) bunrouter.HandlerFunc
CorsMiddleware() func(bunrouter.HandlerFunc) bunrouter.HandlerFunc
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/application/service/user_service_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"example.com/domain"
)

//go:generate mockgen -source=user_service_interface.go -destination=../../mocks/user_service_mock.go -package=mocks
//go:generate gomockhandler -config=$EXAMPLE_TESTS_ROOT/gomockhandler.json -source=$GOFILE -destination=mock_$GOPACKAGE/mock_$GOFILE -package=mock_$GOPACKAGE
type UserServiceInterface interface {
Add(ctx context.Context, name string) (string, error)
UpdateUser(ctx context.Context, user domain.User) error
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/domain/repository/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"example.com/domain"
)

//go:generate mockgen -source=user.go -destination=../../mocks/user_mock.go -package=mocks
//go:generate gomockhandler -config=$EXAMPLE_TESTS_ROOT/gomockhandler.json -source=$GOFILE -destination=mock_$GOPACKAGE/mock_$GOFILE -package=mock_$GOPACKAGE
type UserRepository interface {
AddUser(ctx context.Context, id, authToken, name string) error
UpdateUser(ctx context.Context, user domain.User) error
Expand Down
2 changes: 1 addition & 1 deletion app/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ go 1.21.1

require (
github.com/go-sql-driver/mysql v1.7.1
github.com/golang/mock v1.6.0
github.com/google/uuid v1.3.1
github.com/uptrace/bun v1.1.16
github.com/uptrace/bun/dialect/mysqldialect v1.1.16
github.com/uptrace/bunrouter v1.0.20
go.uber.org/mock v0.3.0
)

require (
Expand Down
27 changes: 25 additions & 2 deletions app/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
Expand All @@ -25,12 +27,33 @@ github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9
github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc=
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
go.uber.org/mock v0.3.0 h1:3mUxI1No2/60yUYax92Pt8eNOEecx2D3lcXZh2NEZJo=
go.uber.org/mock v0.3.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
2 changes: 1 addition & 1 deletion app/interface/handler/handler_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package _interface

import "github.com/uptrace/bunrouter"

//go:generate mockgen -source=handler_interface.go -destination=../../mocks/handler_mock.go -package=mocks
//go:generate gomockhandler -config=$EXAMPLE_TESTS_ROOT/gomockhandler.json -source=$GOFILE -destination=mock_$GOPACKAGE/mock_$GOFILE -package=mock_$GOPACKAGE
type UserHandlerInterface interface {
UserCreateHandle() bunrouter.HandlerFunc
UserGetHandle() bunrouter.HandlerFunc
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions gomockhandler.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"mocks": {
"app/application/middleware/mock_middleware/mock_auth_interface.go": {
"checksum": "K3mIu7OMX7MwxnCjmiNj3w==",
"source_checksum": "Biu21js4aqYMt9D++o7xYg==",
"mode": "SOURCE_MODE",
"source_mode_runner": {
"source": "app/application/middleware/auth_interface.go",
"destination": "app/application/middleware/mock_middleware/mock_auth_interface.go",
"package": "mock_middleware"
}
},
"app/application/service/mock_service/mock_user_service_interface.go": {
"checksum": "/THJPtz1/AjoFUmW8wrEBw==",
"source_checksum": "lmESALEeIbdXj7kzuANZhg==",
"mode": "SOURCE_MODE",
"source_mode_runner": {
"source": "app/application/service/user_service_interface.go",
"destination": "app/application/service/mock_service/mock_user_service_interface.go",
"package": "mock_service"
}
},
"app/domain/repository/mock_repository/mock_user.go": {
"checksum": "gtyb9qgT5CJmzU02yszMcQ==",
"source_checksum": "TK9DZtubihm8bygk0eE3PA==",
"mode": "SOURCE_MODE",
"source_mode_runner": {
"source": "app/domain/repository/user.go",
"destination": "app/domain/repository/mock_repository/mock_user.go",
"package": "mock_repository"
}
},
"app/interface/handler/mock__interface/mock_handler_interface.go": {
"checksum": "W707zjcJELN+P5lPMTkq3w==",
"source_checksum": "eAVARHyK054If9xuw+XKPA==",
"mode": "SOURCE_MODE",
"source_mode_runner": {
"source": "app/interface/handler/handler_interface.go",
"destination": "app/interface/handler/mock__interface/mock_handler_interface.go",
"package": "mock__interface"
}
}
}
}

0 comments on commit c1067b3

Please sign in to comment.