forked from mirrors/homebox
31b34241e0
* change /content/ -> /homebox/ * add cache to code generators * update env variables to set data storage * update env variables * set env variables in prod container * implement attachment post route (WIP) * get attachment endpoint * attachment download * implement string utilities lib * implement generic drop zone * use explicit truncate * remove clean dir * drop strings composable for lib * update item types and add attachments * add attachment API * implement service context * consolidate API code * implement editing attachments * implement upload limit configuration * improve error handling * add docs for max upload size * fix test cases
39 lines
729 B
Go
39 lines
729 B
Go
package services
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/hay-kot/homebox/backend/internal/types"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func Test_SetAuthContext(t *testing.T) {
|
|
user := &types.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)
|
|
}
|