ci / api / api (push) Successful in 55s
release / release (версия и заметки) (push) Successful in 5s
ci / mobile / mobile (Metro-бандл Android) (push) Successful in 1m21s
ci / ts / ts (packages + web) (push) Successful in 2m19s
release / android (APK в релиз) (push) Successful in 4m45s
release / desktop (Linux и Windows в релиз) (push) Successful in 20m58s
release / prune (старые файлы и прогоны) (push) Successful in 9s
ci / module boundaries / boundaries (push) Successful in 7s
ci / contract / contract (сгенерированный код совпадает с openapi.yaml) (push) Successful in 1m35s
ci / db / db (push) Successful in 59s
36 lines
1.4 KiB
Go
36 lines
1.4 KiB
Go
package playback
|
||
|
||
import (
|
||
"context"
|
||
"github.com/google/uuid"
|
||
"github.com/stretchr/testify/require"
|
||
"pipu/api/internal/api/gen"
|
||
"pipu/api/internal/platform/apperr"
|
||
"strings"
|
||
"testing"
|
||
)
|
||
|
||
func TestValidatePlaylist(t *testing.T) {
|
||
id := uuid.New()
|
||
require.NoError(t, validatePlaylist(" В дорогу ", "", []uuid.UUID{id}))
|
||
require.NoError(t, validatePlaylist(strings.Repeat("я", 120), strings.Repeat("я", 2000), nil))
|
||
for _, name := range []string{"", " \t\n", strings.Repeat("я", 121)} {
|
||
require.Error(t, validatePlaylist(name, "", nil))
|
||
}
|
||
require.Error(t, validatePlaylist("Mix", strings.Repeat("я", 2001), nil))
|
||
require.Error(t, validatePlaylist("Mix", "", []uuid.UUID{id, id}))
|
||
require.Error(t, validatePlaylist("Mix", "", []uuid.UUID{uuid.Nil}))
|
||
require.Error(t, validatePlaylist("Mix", "", make([]uuid.UUID, 2001)))
|
||
}
|
||
|
||
func TestPlaylistSharingRequiresAuthentication(t *testing.T) {
|
||
h := &Handler{}
|
||
ctx := context.Background()
|
||
_, err := h.SharePlaylist(ctx, gen.SharePlaylistRequestObject{Id: uuid.New()})
|
||
require.ErrorIs(t, err, apperr.Unauthorized("auth.unauthorized", ""))
|
||
_, err = h.RevokePlaylistShare(ctx, gen.RevokePlaylistShareRequestObject{Id: uuid.New()})
|
||
require.ErrorIs(t, err, apperr.Unauthorized("auth.unauthorized", ""))
|
||
_, err = h.GetSharedPlaylist(ctx, gen.GetSharedPlaylistRequestObject{ShareId: uuid.New()})
|
||
require.ErrorIs(t, err, apperr.Unauthorized("auth.unauthorized", ""))
|
||
}
|