mirror of
https://github.com/hay-kot/homebox.git
synced 2024-11-17 14:18:43 +00:00
343290a55a
* cleanup unnecessary mocks * refactor document storage location * remove unused function * move ownership to document types to repo package * move types and mappers to repo package * refactor sets to own package
39 lines
727 B
Go
39 lines
727 B
Go
package services
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/hay-kot/homebox/backend/internal/repo"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func Test_SetAuthContext(t *testing.T) {
|
|
user := &repo.UserOut{
|
|
ID: uuid.New(),
|
|
}
|
|
|
|
token := uuid.New().String()
|
|
|
|
ctx := SetUserCtx(context.Background(), user, token)
|
|
|
|
ctxUser := UseUserCtx(ctx)
|
|
|
|
assert.NotNil(t, ctxUser)
|
|
assert.Equal(t, user.ID, ctxUser.ID)
|
|
|
|
ctxUserToken := UseTokenCtx(ctx)
|
|
assert.NotEmpty(t, ctxUserToken)
|
|
}
|
|
|
|
func Test_SetAuthContext_Nulls(t *testing.T) {
|
|
ctx := SetUserCtx(context.Background(), nil, "")
|
|
|
|
ctxUser := UseUserCtx(ctx)
|
|
|
|
assert.Nil(t, ctxUser)
|
|
|
|
ctxUserToken := UseTokenCtx(ctx)
|
|
assert.Empty(t, ctxUserToken)
|
|
}
|