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 1 commit
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
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"
}
}
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,7 @@ ent-db:
# eslintの実行
run-eslint:
docker compose exec view npm run lint

# apiテストの実行
run-test:
docker compose exec api go test ./test -v
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
9 changes: 5 additions & 4 deletions api/drivers/server/server.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package server

import (
"net/http"
"os"

_ "github.com/NUTFes/FinanSu/api/docs"
"github.com/NUTFes/FinanSu/api/router"
"github.com/labstack/echo/v4"

Check failure on line 9 in api/drivers/server/server.go

View workflow job for this annotation

GitHub Actions / golangci-lint

"github.com/labstack/echo/v4" imported but not used (typecheck)
Kubosaka marked this conversation as resolved.
Show resolved Hide resolved
"github.com/labstack/echo/v4/middleware"
echoSwagger "github.com/swaggo/echo-swagger"
"net/http"
"os"
)

func RunServer(router router.Router) {
func RunServer(router router.Router) *echo.Echo {

Check failure on line 14 in api/drivers/server/server.go

View workflow job for this annotation

GitHub Actions / golangci-lint

undeclared name: `echo` (typecheck)
Kubosaka marked this conversation as resolved.
Show resolved Hide resolved
// echoのインスタンス
e := echo.New()

Check failure on line 16 in api/drivers/server/server.go

View workflow job for this annotation

GitHub Actions / golangci-lint

undeclared name: `echo` (typecheck)
Kubosaka marked this conversation as resolved.
Show resolved Hide resolved

// Middleware
e.Use(middleware.Recover())
Expand All @@ -39,5 +40,5 @@
e.GET("/swagger/*", echoSwagger.WrapHandler)

// サーバー起動
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
}
}

94 changes: 82 additions & 12 deletions api/go.mod
Original file line number Diff line number Diff line change
@@ -1,24 +1,94 @@
module github.com/NUTFes/FinanSu/api

go 1.16
go 1.21

toolchain go1.23.2

require (
github.com/go-sql-driver/mysql v1.6.0
github.com/joho/godotenv v1.4.0
github.com/kr/pretty v0.3.1 // indirect
github.com/go-sql-driver/mysql v1.8.1
github.com/go-testfixtures/testfixtures/v3 v3.13.0
github.com/joho/godotenv v1.5.1
github.com/labstack/echo/v4 v4.9.0
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/pkg/errors v0.9.1
github.com/slack-go/slack v0.13.0
github.com/stretchr/testify v1.8.1 // indirect
github.com/stretchr/testify v1.9.0
github.com/swaggo/echo-swagger v1.3.5
github.com/swaggo/swag v1.8.1
golang.org/x/crypto v0.3.0
golang.org/x/net v0.7.0 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
golang.org/x/tools v0.4.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
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.8 // 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
Kubosaka marked this conversation as resolved.
Show resolved Hide resolved
cloud.google.com/go/monitoring v1.21.1 // indirect
cloud.google.com/go/spanner v1.70.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/KyleBanks/depth v1.2.1 // 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-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/spec v0.20.4 // indirect
github.com/go-openapi/swag v0.19.15 // 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.4.2 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.4 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/labstack/gommon v0.3.1 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // 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/swaggo/files v0.0.0-20220728132757-551d4a08d97a // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.1 // 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.8.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
golang.org/x/tools v0.24.0 // indirect
google.golang.org/api v0.201.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.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading
Loading