Skip to content

Conversation

@Kubosaka
Copy link
Collaborator

@Kubosaka Kubosaka commented Dec 4, 2024

概要

  • APIテストの導入

画面スクリーンショット等

  • URL
    スクリーンショット

テスト項目

  • make run-testでテストが実行できるか確認する

備考

This pull request includes several changes to enhance the Go project, including updates to the project dependencies, improvements to the server initialization, and the addition of new test fixtures and test cases. The most important changes are summarized below:

Dependencies and Configuration:

  • Updated Go version and dependencies in api/go.mod to ensure compatibility and include new packages.
  • Added Go-specific editor settings in .vscode/settings.json to use the golang.go formatter.

Server Initialization and Testing:

  • Modified func RunServer in api/drivers/server/server.go to return an *echo.Echo instance, facilitating better testability. [1] [2]
  • Updated func InitializeServer in api/internals/di/di.go to return both db.Client and *echo.Echo, and added a new InitializeTestServer function for setting up the test environment. [1] [2]
  • Added test fixtures in api/test/fixtures/users.yml and comprehensive test cases in api/test/sample_test.go to ensure robust testing of the API endpoints. [1] [2]

Database and Docker:

  • Added scripts and SQL files to set up a test database in the Docker environment, ensuring isolation and consistency for tests. [1] [2] [3] [4]

Minor Code Improvements:

  • Cleaned up import statements and minor refactoring in various files to improve code readability and maintainability. [1] [2] [3] [4] [5]

These changes collectively improve the project's structure, testability, and maintainability.

@Kubosaka Kubosaka self-assigned this Dec 8, 2024
@@ -0,0 +1,12 @@
use finansu_test_db;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODOこんな感じてテストDBもテーブル作る

@hikahana
Copy link
Collaborator

以下のようになるんですけどここはどうする系ですか。

go test ./api/test
# _/home/hnhk/FinanSu/api/test
api/test/sample_test.go:13:2: cannot find package "github.com/NUTFes/FinanSu/api/internals/di" in any of:
        /usr/lib/go-1.23/src/github.com/NUTFes/FinanSu/api/internals/di (from $GOROOT)
        /home/hnhk/go/src/github.com/NUTFes/FinanSu/api/internals/di (from $GOPATH)
FAIL    _/home/hnhk/FinanSu/api/test [setup failed]
FAIL

@Kubosaka
Copy link
Collaborator Author

@hikahana
#897 (comment)
テストは、コンテナ内での実行することを想定しています。
make run-testでどうですか?

Copy link
Collaborator

@hikahana hikahana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hikahana
Copy link
Collaborator

@Kubosaka
コンフリクト解消お願いします!

@Kubosaka Kubosaka merged commit 6ae3ae1 into develop Jan 22, 2025
1 check passed
@Kubosaka Kubosaka deleted the feat/kubosaka/intro-test branch January 22, 2025 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants