Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
kripsy committed Nov 8, 2023
1 parent aac2de4 commit 659f346
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion internal/client/infrastrucrure/filemanager/userauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type userAuth struct {
userFilePath string
}

//nolint:revive
//nolint:revive,nolintlint
func NewUserAuth(userPath string) (*userAuth, error) {
if _, err := os.Stat(userPath); os.IsNotExist(err) {
if err = os.MkdirAll(userPath, permissions.DirMode); err != nil {
Expand Down
12 changes: 8 additions & 4 deletions internal/server/controller/middleware_grpc_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package controller_test

import (
"context"
"errors"
"testing"
"time"

Expand Down Expand Up @@ -123,13 +124,14 @@ func TestAuthInterceptor(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
var ErrContext = errors.New("context error")
testHandler := func(ctx context.Context, req interface{}) (interface{}, error) {
if tt.isProtected {
if ctx.Value(utils.USERNAMECONTEXTKEY) != userName {
t.Errorf("Username in context is incorrect")
return "", ErrContext
}
if ctx.Value(utils.USERIDCONTEXTKEY) != userID {
t.Errorf("UserID in context is incorrect")
return "", ErrContext
}
}

Expand Down Expand Up @@ -159,8 +161,10 @@ func TestAuthInterceptor(t *testing.T) {

_, err := middleware.AuthInterceptor(ctx, nil, info, testHandler)

if (err != nil) != tt.wantErr {
t.Errorf("AuthInterceptor() error = %v, wantErr %v", err, tt.wantErr)
if tt.wantErr {
assert.Error(t, err)
} else {
assert.NoError(t, err)
}
})
}
Expand Down

0 comments on commit 659f346

Please sign in to comment.