From fb925604ed044e4dd844ad0c1d8a8bcb0ee29dd0 Mon Sep 17 00:00:00 2001 From: NitiwatOwen Date: Mon, 1 Jan 2024 19:27:18 +0700 Subject: [PATCH] fix: package --- Makefile | 8 ++++---- database/postgresql.connection.go | 2 +- internal/service/token/token.service.go | 4 ++-- mocks/repository/auth/auth.mock.go | 8 ++++---- mocks/repository/cache/cache.mock.go | 6 +++--- mocks/service/token/token.mock.go | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 4bd008c..4f6ced1 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,13 @@ server: - go run ./src/. + go run ./cmd/. mock-gen: - mockgen -source ./src/pkg/repository/cache/cache.repository.go -destination ./src/mocks/repository/cache/cache.mock.go - mockgen -source ./src/pkg/repository/auth/auth.repository.go -destination ./src/mocks/repository/auth/auth.mock.go + mockgen -source ./pkg/repository/cache/cache.repository.go -destination ./mocks/repository/cache/cache.mock.go + mockgen -source ./pkg/repository/auth/auth.repository.go -destination ./mocks/repository/auth/auth.mock.go test: go vet ./... - go test -v -coverpkg ./src/internal/... -coverprofile coverage.out -covermode count ./src/internal/... + go test -v -coverpkg ./internal/... -coverprofile coverage.out -covermode count ./internal/... go tool cover -func=coverage.out go tool cover -html=coverage.out -o coverage.html diff --git a/database/postgresql.connection.go b/database/postgresql.connection.go index 3bcd4fe..60b6a5b 100644 --- a/database/postgresql.connection.go +++ b/database/postgresql.connection.go @@ -3,7 +3,7 @@ package database import ( "fmt" "github.com/isd-sgcu/johnjud-auth/cfgldr" - "github.com/isd-sgcu/johnjud-auth/src/internal/domain/model" + "github.com/isd-sgcu/johnjud-auth/internal/domain/model" "gorm.io/driver/postgres" "gorm.io/gorm" gormLogger "gorm.io/gorm/logger" diff --git a/internal/service/token/token.service.go b/internal/service/token/token.service.go index 3874acf..2accd4c 100644 --- a/internal/service/token/token.service.go +++ b/internal/service/token/token.service.go @@ -82,7 +82,7 @@ func (s *serviceImpl) Validate(token string) (*tokenDto.UserCredential, error) { return nil, errors.New("expired token") } - accessTokenCache := &token.AccessTokenCache{} + accessTokenCache := &tokenDto.AccessTokenCache{} err = s.accessTokenCache.GetValue(payloads["auth_session_id"].(string), accessTokenCache) if err != nil { if err != redis.Nil { @@ -95,7 +95,7 @@ func (s *serviceImpl) Validate(token string) (*tokenDto.UserCredential, error) { return nil, errors.New("invalid token") } - userCredential := &token.UserCredential{ + userCredential := &tokenDto.UserCredential{ UserID: payloads["user_id"].(string), Role: accessTokenCache.Role, AuthSessionID: payloads["auth_session_id"].(string), diff --git a/mocks/repository/auth/auth.mock.go b/mocks/repository/auth/auth.mock.go index f136644..8b0970d 100644 --- a/mocks/repository/auth/auth.mock.go +++ b/mocks/repository/auth/auth.mock.go @@ -1,14 +1,14 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: ./src/pkg/repository/auth/auth.repository.go +// Source: ./pkg/repository/auth/auth.repository.go // Package mock_auth is a generated GoMock package. package mock_auth import ( - "github.com/isd-sgcu/johnjud-auth/internal/domain/model" - "reflect" + reflect "reflect" - "github.com/golang/mock/gomock" + gomock "github.com/golang/mock/gomock" + model "github.com/isd-sgcu/johnjud-auth/internal/domain/model" ) // MockRepository is a mock of Repository interface. diff --git a/mocks/repository/cache/cache.mock.go b/mocks/repository/cache/cache.mock.go index 2d20fdc..7102795 100644 --- a/mocks/repository/cache/cache.mock.go +++ b/mocks/repository/cache/cache.mock.go @@ -1,13 +1,13 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: ./src/pkg/repository/cache/cache.repository.go +// Source: ./pkg/repository/cache/cache.repository.go // Package mock_cache is a generated GoMock package. package mock_cache import ( - "reflect" + reflect "reflect" - "github.com/golang/mock/gomock" + gomock "github.com/golang/mock/gomock" ) // MockRepository is a mock of Repository interface. diff --git a/mocks/service/token/token.mock.go b/mocks/service/token/token.mock.go index 5c8a5df..0be8264 100644 --- a/mocks/service/token/token.mock.go +++ b/mocks/service/token/token.mock.go @@ -23,7 +23,7 @@ func (m *TokenServiceMock) CreateCredential(userId string, role constant.Role, a func (m *TokenServiceMock) Validate(token string) (*tokenDto.UserCredential, error) { args := m.Called(token) if args.Get(0) != nil { - return args.Get(0).(*token.UserCredential), nil + return args.Get(0).(*tokenDto.UserCredential), nil } return nil, args.Error(1)