Skip to content

Commit

Permalink
Fix API import aliases
Browse files Browse the repository at this point in the history
Signed-off-by: Dusan Borovcanin <[email protected]>
  • Loading branch information
dborovcanin committed Dec 19, 2024
1 parent c4d17e3 commit ac0eade
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 37 deletions.
4 changes: 2 additions & 2 deletions channels/api/http/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (
"testing"
"time"

httpapi "github.com/absmach/supermq/api/http"
apiutil "github.com/absmach/supermq/api/http/util"
"github.com/absmach/supermq/channels"
"github.com/absmach/supermq/channels/mocks"
"github.com/absmach/supermq/clients"
smqapi "github.com/absmach/supermq/internal/api"
"github.com/absmach/supermq/internal/testsutil"
smqlog "github.com/absmach/supermq/logger"
smqauthn "github.com/absmach/supermq/pkg/authn"
Expand Down Expand Up @@ -517,7 +517,7 @@ func TestListChannels(t *testing.T) {
desc: "list channels with limit greater than max",
token: validToken,
domainID: validID,
query: fmt.Sprintf("limit=%d", smqapi.MaxLimitSize+1),
query: fmt.Sprintf("limit=%d", httpapi.MaxLimitSize+1),
status: http.StatusBadRequest,
err: apiutil.ErrValidation,
},
Expand Down
4 changes: 2 additions & 2 deletions clients/api/http/endpoints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/0x6flab/namegenerator"
apiutil "github.com/absmach/supermq/api/http/util"
"github.com/absmach/supermq/clients"
httpapi "github.com/absmach/supermq/clients/api/http"
clientsapi "github.com/absmach/supermq/clients/api/http"
"github.com/absmach/supermq/clients/mocks"
"github.com/absmach/supermq/internal/api"
"github.com/absmach/supermq/internal/testsutil"
Expand Down Expand Up @@ -93,7 +93,7 @@ func newClientsServer() (*httptest.Server, *mocks.Service, *authnmocks.Authentic

logger := smqlog.NewMock()
mux := chi.NewRouter()
httpapi.MakeHandler(svc, authn, mux, logger, "")
clientsapi.MakeHandler(svc, authn, mux, logger, "")

return httptest.NewServer(mux), svc, authn
}
Expand Down
4 changes: 2 additions & 2 deletions domains/api/http/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

apiutil "github.com/absmach/supermq/api/http/util"
"github.com/absmach/supermq/domains"
httpapi "github.com/absmach/supermq/domains/api/http"
domainsapi "github.com/absmach/supermq/domains/api/http"
"github.com/absmach/supermq/domains/mocks"
"github.com/absmach/supermq/internal/api"
"github.com/absmach/supermq/internal/testsutil"
Expand Down Expand Up @@ -93,7 +93,7 @@ func newDomainsServer() (*httptest.Server, *mocks.Service, *authnmock.Authentica
svc := new(mocks.Service)
authn := new(authnmock.Authentication)
mux := chi.NewMux()
httpapi.MakeHandler(svc, authn, mux, logger, "")
domainsapi.MakeHandler(svc, authn, mux, logger, "")
return httptest.NewServer(mux), svc, authn
}

Expand Down
4 changes: 2 additions & 2 deletions groups/api/http/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (
"testing"
"time"

httpapi "github.com/absmach/supermq/api/http"
apiutil "github.com/absmach/supermq/api/http/util"
"github.com/absmach/supermq/groups"
"github.com/absmach/supermq/groups/mocks"
smqapi "github.com/absmach/supermq/internal/api"
"github.com/absmach/supermq/internal/testsutil"
smqlog "github.com/absmach/supermq/logger"
smqauthn "github.com/absmach/supermq/pkg/authn"
Expand Down Expand Up @@ -763,7 +763,7 @@ func TestListGroups(t *testing.T) {
desc: "list groups with limit greater than max",
token: validToken,
domainID: validID,
query: fmt.Sprintf("limit=%d", smqapi.MaxLimitSize+1),
query: fmt.Sprintf("limit=%d", httpapi.MaxLimitSize+1),
status: http.StatusBadRequest,
err: apiutil.ErrValidation,
},
Expand Down
18 changes: 9 additions & 9 deletions pkg/sdk/domains_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
"testing"
"time"

httpapi "github.com/absmach/supermq/api/http"
apiutil "github.com/absmach/supermq/api/http/util"
"github.com/absmach/supermq/domains"
httpapi "github.com/absmach/supermq/domains/api/http"
domainapi "github.com/absmach/supermq/domains/api/http"
"github.com/absmach/supermq/domains/mocks"
internalapi "github.com/absmach/supermq/internal/api"
"github.com/absmach/supermq/internal/testsutil"
smqlog "github.com/absmach/supermq/logger"
smqauthn "github.com/absmach/supermq/pkg/authn"
Expand Down Expand Up @@ -50,7 +50,7 @@ func setupDomains() (*httptest.Server, *mocks.Service, *authnmocks.Authenticatio
mux := chi.NewRouter()
authn := new(authnmocks.Authentication)

mux = httpapi.MakeHandler(svc, authn, mux, logger, "")
mux = domainapi.MakeHandler(svc, authn, mux, logger, "")
return httptest.NewServer(mux), svc, authn
}

Expand Down Expand Up @@ -458,8 +458,8 @@ func TestListDomians(t *testing.T) {
svcReq: domains.Page{
Offset: 0,
Limit: 10,
Order: internalapi.DefOrder,
Dir: internalapi.DefDir,
Order: httpapi.DefOrder,
Dir: httpapi.DefDir,
},
svcRes: domains.DomainsPage{
Total: 1,
Expand All @@ -484,8 +484,8 @@ func TestListDomians(t *testing.T) {
svcReq: domains.Page{
Offset: 0,
Limit: 10,
Order: internalapi.DefOrder,
Dir: internalapi.DefDir,
Order: httpapi.DefOrder,
Dir: httpapi.DefDir,
},
svcRes: domains.DomainsPage{},
authnErr: svcerr.ErrAuthentication,
Expand Down Expand Up @@ -531,8 +531,8 @@ func TestListDomians(t *testing.T) {
svcReq: domains.Page{
Offset: 0,
Limit: 10,
Order: internalapi.DefOrder,
Dir: internalapi.DefDir,
Order: httpapi.DefOrder,
Dir: httpapi.DefDir,
},
svcRes: domains.DomainsPage{
Total: 1,
Expand Down
34 changes: 17 additions & 17 deletions pkg/sdk/users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"strings"
"testing"

httpapi "github.com/absmach/supermq/api/http"
apiutil "github.com/absmach/supermq/api/http/util"
authmocks "github.com/absmach/supermq/auth/mocks"
internalapi "github.com/absmach/supermq/internal/api"
grpcTokenV1 "github.com/absmach/supermq/internal/grpc/token/v1"
smqlog "github.com/absmach/supermq/logger"
"github.com/absmach/supermq/pkg/authn"
Expand Down Expand Up @@ -320,8 +320,8 @@ func TestListUsers(t *testing.T) {
svcReq: users.Page{
Offset: offset,
Limit: limit,
Order: internalapi.DefOrder,
Dir: internalapi.DefDir,
Order: httpapi.DefOrder,
Dir: httpapi.DefDir,
},
svcRes: users.UsersPage{
Page: users.Page{
Expand All @@ -348,8 +348,8 @@ func TestListUsers(t *testing.T) {
svcReq: users.Page{
Offset: offset,
Limit: limit,
Order: internalapi.DefOrder,
Dir: internalapi.DefDir,
Order: httpapi.DefOrder,
Dir: httpapi.DefDir,
},
svcRes: users.UsersPage{},
svcErr: svcerr.ErrAuthentication,
Expand Down Expand Up @@ -381,8 +381,8 @@ func TestListUsers(t *testing.T) {
svcReq: users.Page{
Offset: offset,
Limit: 10,
Order: internalapi.DefOrder,
Dir: internalapi.DefDir,
Order: httpapi.DefOrder,
Dir: httpapi.DefDir,
},
svcRes: users.UsersPage{
Page: users.Page{
Expand Down Expand Up @@ -423,8 +423,8 @@ func TestListUsers(t *testing.T) {
Offset: offset,
Limit: limit,
Metadata: users.Metadata{"name": "user_99"},
Order: internalapi.DefOrder,
Dir: internalapi.DefDir,
Order: httpapi.DefOrder,
Dir: httpapi.DefDir,
},
svcRes: users.UsersPage{
Page: users.Page{
Expand Down Expand Up @@ -453,8 +453,8 @@ func TestListUsers(t *testing.T) {
Offset: offset,
Limit: limit,
Status: users.DisabledStatus,
Order: internalapi.DefOrder,
Dir: internalapi.DefDir,
Order: httpapi.DefOrder,
Dir: httpapi.DefDir,
},
svcRes: users.UsersPage{
Page: users.Page{
Expand Down Expand Up @@ -483,8 +483,8 @@ func TestListUsers(t *testing.T) {
Offset: offset,
Limit: limit,
Tag: "tag1",
Order: internalapi.DefOrder,
Dir: internalapi.DefDir,
Order: httpapi.DefOrder,
Dir: httpapi.DefDir,
},
svcRes: users.UsersPage{
Page: users.Page{
Expand Down Expand Up @@ -514,8 +514,8 @@ func TestListUsers(t *testing.T) {
svcReq: users.Page{
Offset: offset,
Limit: limit,
Order: internalapi.DefOrder,
Dir: internalapi.DefDir,
Order: httpapi.DefOrder,
Dir: httpapi.DefDir,
},
svcRes: users.UsersPage{},
svcErr: nil,
Expand All @@ -532,8 +532,8 @@ func TestListUsers(t *testing.T) {
svcReq: users.Page{
Offset: offset,
Limit: limit,
Order: internalapi.DefOrder,
Dir: internalapi.DefDir,
Order: httpapi.DefOrder,
Dir: httpapi.DefDir,
},
svcRes: users.UsersPage{
Page: users.Page{
Expand Down
3 changes: 2 additions & 1 deletion tools/config/golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ linters-settings:
alias: sdkmocks
- pkg: github.com/absmach/supermq/api/http/util
alias: apiutil

- pkg: github.com/absmach/supermq/api/http
alias: httpapi
gocritic:
enabled-checks:
- importShadow
Expand Down
4 changes: 2 additions & 2 deletions users/api/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
svcerr "github.com/absmach/supermq/pkg/errors/service"
oauth2mocks "github.com/absmach/supermq/pkg/oauth2/mocks"
"github.com/absmach/supermq/users"
httpapi "github.com/absmach/supermq/users/api"
usersapi "github.com/absmach/supermq/users/api"
"github.com/absmach/supermq/users/mocks"
"github.com/go-chi/chi/v5"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -93,7 +93,7 @@ func newUsersServer() (*httptest.Server, *mocks.Service, *authnmocks.Authenticat
provider.On("Name").Return("test")
authn := new(authnmocks.Authentication)
token := new(authmocks.TokenServiceClient)
httpapi.MakeHandler(svc, authn, token, true, mux, logger, "", passRegex, provider)
usersapi.MakeHandler(svc, authn, token, true, mux, logger, "", passRegex, provider)

return httptest.NewServer(mux), svc, authn
}
Expand Down

0 comments on commit ac0eade

Please sign in to comment.