-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from voltgizerz/develop
Develop
- Loading branch information
Showing
11 changed files
with
245 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,3 +26,6 @@ mocks: | |
|
||
changelog: | ||
- CHANGELOG.md | ||
|
||
migration: | ||
- database/migrations/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-- +goose Up | ||
-- +goose StatementBegin | ||
CREATE TABLE `users` ( | ||
`id` bigint NOT NULL AUTO_INCREMENT, | ||
`name` varchar(255) DEFAULT NULL, | ||
`username` varchar(255) DEFAULT NULL, | ||
`email` varchar(255) DEFAULT NULL, | ||
`password_hashed` varchar(528) DEFAULT NULL, | ||
`is_active` tinyint(1) NOT NULL, | ||
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; | ||
-- +goose StatementEnd | ||
|
||
-- +goose Down | ||
-- +goose StatementBegin | ||
DROP TABLE `users`; | ||
-- +goose StatementEnd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package handler | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"go.uber.org/mock/gomock" | ||
|
||
"github.com/voltgizerz/POS-restaurant/internal/app/mocks" | ||
"github.com/voltgizerz/POS-restaurant/pkg/logger" | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
// Setup code (if any) | ||
// ... | ||
logger.Init() | ||
// Run the tests | ||
m.Run() | ||
} | ||
|
||
type MockObject struct { | ||
MockUserRepo *mocks.MockIUserRepository | ||
MockAuthService *mocks.MockIAuth | ||
MockUserService *mocks.MockIUserService | ||
} | ||
|
||
func NewMock(t *testing.T) (*gomock.Controller, *MockObject) { | ||
setTestENV() | ||
ctrl := gomock.NewController(t) | ||
mockUserRepo := mocks.NewMockIUserRepository(ctrl) | ||
mockAuthService := mocks.NewMockIAuth(ctrl) | ||
mockUserService := mocks.NewMockIUserService(ctrl) | ||
|
||
mockObj := &MockObject{ | ||
MockUserRepo: mockUserRepo, | ||
MockAuthService: mockAuthService, | ||
MockUserService: mockUserService, | ||
} | ||
|
||
return ctrl, mockObj | ||
} | ||
|
||
func setTestENV() { | ||
os.Setenv("GO_ENV", "unit_test") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package handler | ||
|
||
// func TestUserHandler_Login(t *testing.T) { | ||
// type args struct { | ||
// c fiber.Ctx | ||
// } | ||
// tests := []struct { | ||
// name string | ||
// args args | ||
// wantErr bool | ||
// setup func(mockObj *MockObject) | ||
// }{{}} | ||
// for _, tt := range tests { | ||
// ctrl, mockObj := NewMock(t) | ||
// if tt.setup != nil { | ||
// tt.setup(mockObj) | ||
// } | ||
// defer ctrl.Finish() | ||
|
||
// userHandler := &UserHandler{ | ||
// authService: mockObj.MockAuthService, | ||
// userService: mockObj.MockUserService, | ||
// } | ||
|
||
// t.Run(tt.name, func(t *testing.T) { | ||
// if err := userHandler.Login(tt.args.c); (err != nil) != tt.wantErr { | ||
// t.Errorf("UserHandler.Login() error = %v, wantErr %v", err, tt.wantErr) | ||
// } | ||
// }) | ||
// } | ||
// } |
Oops, something went wrong.