Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apiテスト導入 #897

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Set up go
uses: actions/setup-go@v2
with:
go-version: 1.14
go-version: 1.16
Kubosaka marked this conversation as resolved.
Show resolved Hide resolved
- name: golangci-lint
uses: reviewdog/action-golangci-lint@v1
with:
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"eslint.workingDirectories": ["./view/next-project"],
"[go]": {
"editor.defaultFormatter": "golang.go"
}
}
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ ent-db:
run-eslint:
docker compose exec view npm run lint

# apiテストの実行
run-test:
docker compose exec api go test ./test -v

generate-openapi:
docker compose run --rm api oapi-codegen -config /openapi/config.yaml /openapi/openapi.yaml

Expand All @@ -83,3 +87,4 @@ run-all:
make run-db
make run
make run-swagger

3 changes: 2 additions & 1 deletion api/drivers/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package db
import (
"database/sql"
"fmt"
"os"

_ "github.com/go-sql-driver/mysql"
"github.com/joho/godotenv"
"os"
)

type client struct {
Expand Down
4 changes: 2 additions & 2 deletions api/drivers/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/labstack/echo/v4/middleware"
)

func RunServer(router router.Router) {
func RunServer(router router.Router) *echo.Echo {
Kubosaka marked this conversation as resolved.
Show resolved Hide resolved
// echoのインスタンス
e := echo.New()
Kubosaka marked this conversation as resolved.
Show resolved Hide resolved

Expand All @@ -35,5 +35,5 @@ func RunServer(router router.Router) {
router.ProvideRouter(e)

// サーバー起動
e.Start(":1323")
return e
Kubosaka marked this conversation as resolved.
Show resolved Hide resolved
}
6 changes: 2 additions & 4 deletions api/externals/controller/user_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,17 @@ func (u *userController) DestroyUser(c echo.Context) error {

// Destroy
func (u *userController) DestroyMultiUsers(c echo.Context) error {
destroyUser := new(domain.DestroyUserIDs)
destroyUser := new(domain.DestroyUserIDs)
if err := c.Bind(destroyUser); err != nil {
return err
}
err := u.u.DestroyMultiUsers(c.Request().Context(), destroyUser.DeleteIDs)
if err != nil {
return c.String(http.StatusBadRequest,err.Error())
return c.String(http.StatusBadRequest, err.Error())
}
return c.String(http.StatusOK, "Destroy Users")
}


// ログインユーザーの取得
func (auth *userController) GetCurrentUser(c echo.Context) error {
// headerからトークンを取得する
Expand All @@ -107,4 +106,3 @@ func (auth *userController) GetCurrentUser(c echo.Context) error {
return nil
}
}

85 changes: 75 additions & 10 deletions api/go.mod
Original file line number Diff line number Diff line change
@@ -1,20 +1,85 @@
module github.com/NUTFes/FinanSu/api

go 1.16
go 1.21

toolchain go1.23.4

require (
github.com/go-sql-driver/mysql v1.6.0
github.com/go-test/deep v1.0.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/joho/godotenv v1.4.0
github.com/go-sql-driver/mysql v1.8.1
github.com/go-testfixtures/testfixtures/v3 v3.14.0
github.com/joho/godotenv v1.5.1
github.com/labstack/echo/v4 v4.11.4
github.com/oapi-codegen/runtime v1.1.1 // indirect
github.com/oapi-codegen/runtime v1.1.1
github.com/pkg/errors v0.9.1
github.com/slack-go/slack v0.13.0
github.com/stretchr/testify v1.9.0 // indirect
golang.org/x/crypto v0.23.0
golang.org/x/net v0.25.0 // indirect
github.com/stretchr/testify v1.9.0
golang.org/x/crypto v0.28.0
gorm.io/driver/mysql v1.3.3
gorm.io/gorm v1.23.4
)

require (
cel.dev/expr v0.16.0 // indirect
cloud.google.com/go v0.116.0 // indirect
cloud.google.com/go/auth v0.9.9 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.4 // indirect
cloud.google.com/go/compute/metadata v0.5.2 // indirect
cloud.google.com/go/iam v1.2.1 // indirect
cloud.google.com/go/longrunning v0.6.1 // indirect
cloud.google.com/go/monitoring v1.21.1 // indirect
cloud.google.com/go/spanner v1.73.0 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/GoogleCloudPlatform/grpc-gcp-go/grpcgcp v1.5.0 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.24.1 // indirect
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cncf/xds/go v0.0.0-20240822171458-6449f94b4d59 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/envoyproxy/go-control-plane v0.13.0 // indirect
github.com/envoyproxy/protoc-gen-validate v1.1.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-test/deep v1.0.8 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/s2a-go v0.1.8 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect
github.com/googleapis/gax-go/v2 v2.13.0 // indirect
github.com/googleapis/go-sql-spanner v1.7.4 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.4 // indirect
github.com/labstack/gommon v0.4.2 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/detectors/gcp v1.29.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
go.opentelemetry.io/otel v1.29.0 // indirect
go.opentelemetry.io/otel/metric v1.29.0 // indirect
go.opentelemetry.io/otel/sdk v1.29.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.29.0 // indirect
go.opentelemetry.io/otel/trace v1.29.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.19.0 // indirect
golang.org/x/time v0.7.0 // indirect
google.golang.org/api v0.203.0 // indirect
google.golang.org/genproto v0.0.0-20241015192408-796eee8c2d53 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect
google.golang.org/grpc v1.67.1 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading
Loading