summaryrefslogtreecommitdiff
path: root/internal/api
diff options
context:
space:
mode:
Diffstat (limited to 'internal/api')
-rw-r--r--internal/api/handlers.go6
-rw-r--r--internal/api/handlers_more_test.go228
-rw-r--r--internal/api/handlers_test.go36
-rw-r--r--internal/api/middleware.go6
-rw-r--r--internal/api/server.go8
5 files changed, 142 insertions, 142 deletions
diff --git a/internal/api/handlers.go b/internal/api/handlers.go
index 8bd8238..fc1d43d 100644
--- a/internal/api/handlers.go
+++ b/internal/api/handlers.go
@@ -14,9 +14,9 @@ import (
"strings"
"time"
- "github.com/paul/kiss-media-player/internal/model"
- "github.com/paul/kiss-media-player/internal/repository"
- "github.com/paul/kiss-media-player/internal/service"
+ "codeberg.org/snonux/play/internal/model"
+ "codeberg.org/snonux/play/internal/repository"
+ "codeberg.org/snonux/play/internal/service"
)
type bootstrapRequest struct {
diff --git a/internal/api/handlers_more_test.go b/internal/api/handlers_more_test.go
index d6e93a8..e7eb99a 100644
--- a/internal/api/handlers_more_test.go
+++ b/internal/api/handlers_more_test.go
@@ -15,12 +15,12 @@ import (
"testing"
"time"
- "github.com/paul/kiss-media-player/internal"
- "github.com/paul/kiss-media-player/internal/auth"
- "github.com/paul/kiss-media-player/internal/clock"
- "github.com/paul/kiss-media-player/internal/model"
- "github.com/paul/kiss-media-player/internal/repository"
- "github.com/paul/kiss-media-player/internal/service"
+ "codeberg.org/snonux/play/internal"
+ "codeberg.org/snonux/play/internal/auth"
+ "codeberg.org/snonux/play/internal/clock"
+ "codeberg.org/snonux/play/internal/model"
+ "codeberg.org/snonux/play/internal/repository"
+ "codeberg.org/snonux/play/internal/service"
)
// ------------------------------------------------------------------
@@ -239,7 +239,7 @@ func TestServer_Bootstrap_hashError(t *testing.T) {
func TestServer_Bootstrap_createUserError(t *testing.T) {
store := &repository.MockStore{
UserRepo: repository.MockUserRepo{
- CountUsersFunc: func(ctx context.Context) (int, error) { return 0, nil },
+ CountUsersFunc: func(ctx context.Context) (int, error) { return 0, nil },
CreateUserFunc: func(ctx context.Context, user *model.User) (int64, error) { return 0, errors.New("boom") },
},
}
@@ -258,7 +258,7 @@ func TestServer_Bootstrap_createUserError(t *testing.T) {
func TestServer_Bootstrap_createSessionError(t *testing.T) {
store := &repository.MockStore{
UserRepo: repository.MockUserRepo{
- CountUsersFunc: func(ctx context.Context) (int, error) { return 0, nil },
+ CountUsersFunc: func(ctx context.Context) (int, error) { return 0, nil },
CreateUserFunc: func(ctx context.Context, user *model.User) (int64, error) { return 1, nil },
},
}
@@ -325,10 +325,10 @@ func TestServer_SetCover(t *testing.T) {
cfg := &internal.Config{SessionTimeoutHours: 24}
tests := []struct {
- name string
- id string
- svcNil bool
- svcErr error
+ name string
+ id string
+ svcNil bool
+ svcErr error
wantCode int
}{
{"nil service", "1", true, nil, http.StatusNotImplemented},
@@ -402,11 +402,11 @@ func TestServer_Upload(t *testing.T) {
cfg := &internal.Config{SessionTimeoutHours: 24, MaxUploadSizeMB: 10}
tests := []struct {
- name string
- id string
- svcNil bool
- svcErr error
- noFile bool
+ name string
+ id string
+ svcNil bool
+ svcErr error
+ noFile bool
wantCode int
}{
{"nil service", "1", true, nil, false, http.StatusNotImplemented},
@@ -471,10 +471,10 @@ func TestServer_Favorite_negative(t *testing.T) {
cfg := &internal.Config{SessionTimeoutHours: 24}
tests := []struct {
- name string
- id string
- svcNil bool
- svcErr error
+ name string
+ id string
+ svcNil bool
+ svcErr error
wantCode int
}{
{"nil service", "1", true, nil, http.StatusNotImplemented},
@@ -525,11 +525,11 @@ func TestServer_RemoveTag_negative(t *testing.T) {
cfg := &internal.Config{SessionTimeoutHours: 24}
tests := []struct {
- name string
- id string
- tag string
- svcNil bool
- svcErr error
+ name string
+ id string
+ tag string
+ svcNil bool
+ svcErr error
wantCode int
}{
{"nil service", "1", "t", true, nil, http.StatusNotImplemented},
@@ -570,11 +570,11 @@ func TestServer_Stream(t *testing.T) {
cfg := &internal.Config{SessionTimeoutHours: 24}
tests := []struct {
- name string
- id string
- svcNil bool
- svcErr error
- res *service.FileResult
+ name string
+ id string
+ svcNil bool
+ svcErr error
+ res *service.FileResult
wantCode int
}{
{"nil service", "1", true, nil, nil, http.StatusNotImplemented},
@@ -614,11 +614,11 @@ func TestServer_Download(t *testing.T) {
cfg := &internal.Config{SessionTimeoutHours: 24}
tests := []struct {
- name string
- id string
- svcNil bool
- svcErr error
- res *service.FileResult
+ name string
+ id string
+ svcNil bool
+ svcErr error
+ res *service.FileResult
wantCode int
wantDisp bool
}{
@@ -665,11 +665,11 @@ func TestServer_Thumbnail(t *testing.T) {
cfg := &internal.Config{SessionTimeoutHours: 24}
tests := []struct {
- name string
- id string
- svcNil bool
- svcErr error
- res *service.FileResult
+ name string
+ id string
+ svcNil bool
+ svcErr error
+ res *service.FileResult
wantCode int
}{
{"nil service", "1", true, nil, nil, http.StatusNotImplemented},
@@ -708,10 +708,10 @@ func TestServer_RegenThumbnail(t *testing.T) {
cfg := &internal.Config{SessionTimeoutHours: 24}
tests := []struct {
- name string
- id string
- svcNil bool
- svcErr error
+ name string
+ id string
+ svcNil bool
+ svcErr error
wantCode int
}{
{"nil service", "1", true, nil, http.StatusNotImplemented},
@@ -752,10 +752,10 @@ func TestServer_CreateShare_negative(t *testing.T) {
cfg := &internal.Config{SessionTimeoutHours: 24, ShareDefaultExpiryDays: 14}
tests := []struct {
- name string
- id string
- svcNil bool
- svcErr error
+ name string
+ id string
+ svcNil bool
+ svcErr error
wantCode int
}{
{"nil service", "1", true, nil, http.StatusNotImplemented},
@@ -791,10 +791,10 @@ func TestServer_ListShares_negative(t *testing.T) {
cfg := &internal.Config{SessionTimeoutHours: 24}
tests := []struct {
- name string
- id string
- svcNil bool
- svcErr error
+ name string
+ id string
+ svcNil bool
+ svcErr error
wantCode int
}{
{"nil service", "1", true, nil, http.StatusNotImplemented},
@@ -830,10 +830,10 @@ func TestServer_RevokeShare(t *testing.T) {
cfg := &internal.Config{SessionTimeoutHours: 24}
tests := []struct {
- name string
- token string
- svcNil bool
- svcErr error
+ name string
+ token string
+ svcNil bool
+ svcErr error
wantCode int
}{
{"nil service", "abc", true, nil, http.StatusNotImplemented},
@@ -867,11 +867,11 @@ func TestServer_SharePage(t *testing.T) {
cfg := &internal.Config{SessionTimeoutHours: 24}
tests := []struct {
- name string
- token string
- svcNil bool
- svcErr error
- share *model.Share
+ name string
+ token string
+ svcNil bool
+ svcErr error
+ share *model.Share
wantCode int
}{
{"nil service", "abc", true, nil, nil, http.StatusNotImplemented},
@@ -906,11 +906,11 @@ func TestServer_ShareStream(t *testing.T) {
cfg := &internal.Config{SessionTimeoutHours: 24}
tests := []struct {
- name string
- token string
- svcNil bool
- svcErr error
- res *service.FileResult
+ name string
+ token string
+ svcNil bool
+ svcErr error
+ res *service.FileResult
wantCode int
}{
{"nil service", "abc", true, nil, nil, http.StatusNotImplemented},
@@ -951,10 +951,10 @@ func TestServer_SoftDelete_negative(t *testing.T) {
cfg := &internal.Config{SessionTimeoutHours: 24}
tests := []struct {
- name string
- id string
- svcNil bool
- svcErr error
+ name string
+ id string
+ svcNil bool
+ svcErr error
wantCode int
}{
{"nil service", "1", true, nil, http.StatusNotImplemented},
@@ -991,10 +991,10 @@ func TestServer_Restore_negative(t *testing.T) {
cfg := &internal.Config{SessionTimeoutHours: 24}
tests := []struct {
- name string
- id string
- svcNil bool
- svcErr error
+ name string
+ id string
+ svcNil bool
+ svcErr error
wantCode int
}{
{"nil service", "1", true, nil, http.StatusNotImplemented},
@@ -1035,11 +1035,11 @@ func TestServer_UpsertNote(t *testing.T) {
cfg := &internal.Config{SessionTimeoutHours: 24}
tests := []struct {
- name string
- id string
- body string
- svcNil bool
- svcErr error
+ name string
+ id string
+ body string
+ svcNil bool
+ svcErr error
wantCode int
}{
{"nil service", "1", `{"content":"hi"}`, true, nil, http.StatusNotImplemented},
@@ -1078,10 +1078,10 @@ func TestServer_DeleteNote(t *testing.T) {
cfg := &internal.Config{SessionTimeoutHours: 24}
tests := []struct {
- name string
- id string
- svcNil bool
- svcErr error
+ name string
+ id string
+ svcNil bool
+ svcErr error
wantCode int
}{
{"nil service", "1", true, nil, http.StatusNotImplemented},
@@ -1167,9 +1167,9 @@ func TestServer_AdminRescan(t *testing.T) {
cfg := &internal.Config{SessionTimeoutHours: 24}
tests := []struct {
- name string
- svcNil bool
- svcErr error
+ name string
+ svcNil bool
+ svcErr error
wantCode int
}{
{"nil service", true, nil, http.StatusNotImplemented},
@@ -1203,9 +1203,9 @@ func TestServer_AdminListTrash(t *testing.T) {
cfg := &internal.Config{SessionTimeoutHours: 24}
tests := []struct {
- name string
- svcNil bool
- svcErr error
+ name string
+ svcNil bool
+ svcErr error
wantCode int
}{
{"nil service", true, nil, http.StatusNotImplemented},
@@ -1239,9 +1239,9 @@ func TestServer_AdminListUsers(t *testing.T) {
cfg := &internal.Config{SessionTimeoutHours: 24}
tests := []struct {
- name string
- svcNil bool
- svcErr error
+ name string
+ svcNil bool
+ svcErr error
wantCode int
}{
{"nil service", true, nil, http.StatusNotImplemented},
@@ -1275,10 +1275,10 @@ func TestServer_AdminCreateUser(t *testing.T) {
cfg := &internal.Config{SessionTimeoutHours: 24}
tests := []struct {
- name string
- body string
- svcNil bool
- svcErr error
+ name string
+ body string
+ svcNil bool
+ svcErr error
wantCode int
}{
{"nil service", `{"username":"bob","password":"pass","is_admin":false}`, true, nil, http.StatusNotImplemented},
@@ -1317,10 +1317,10 @@ func TestServer_AdminDeleteUser(t *testing.T) {
cfg := &internal.Config{SessionTimeoutHours: 24}
tests := []struct {
- name string
- id string
- svcNil bool
- svcErr error
+ name string
+ id string
+ svcNil bool
+ svcErr error
wantCode int
}{
{"nil service", "2", true, nil, http.StatusNotImplemented},
@@ -1355,9 +1355,9 @@ func TestServer_AdminListPermissions(t *testing.T) {
cfg := &internal.Config{SessionTimeoutHours: 24}
tests := []struct {
- name string
- svcNil bool
- svcErr error
+ name string
+ svcNil bool
+ svcErr error
wantCode int
}{
{"nil service", true, nil, http.StatusNotImplemented},
@@ -1391,10 +1391,10 @@ func TestServer_AdminGrantPermission(t *testing.T) {
cfg := &internal.Config{SessionTimeoutHours: 24}
tests := []struct {
- name string
- body string
- svcNil bool
- svcErr error
+ name string
+ body string
+ svcNil bool
+ svcErr error
wantCode int
}{
{"nil service", `{"set_id":1,"user_id":2,"role":"viewer"}`, true, nil, http.StatusNotImplemented},
@@ -1430,10 +1430,10 @@ func TestServer_AdminRevokePermission(t *testing.T) {
cfg := &internal.Config{SessionTimeoutHours: 24}
tests := []struct {
- name string
- body string
- svcNil bool
- svcErr error
+ name string
+ body string
+ svcNil bool
+ svcErr error
wantCode int
}{
{"nil service", `{"set_id":1,"user_id":2}`, true, nil, http.StatusNotImplemented},
@@ -1469,8 +1469,8 @@ func TestServer_AdminRevokePermission(t *testing.T) {
type errHasher struct{}
-func (e *errHasher) Hash(password string) (string, error) { return "", errors.New("hash err") }
-func (e *errHasher) Compare(hash, password string) error { return errors.New("compare err") }
+func (e *errHasher) Hash(password string) (string, error) { return "", errors.New("hash err") }
+func (e *errHasher) Compare(hash, password string) error { return errors.New("compare err") }
// ------------------------------------------------------------------
// parseMediaListQuery
diff --git a/internal/api/handlers_test.go b/internal/api/handlers_test.go
index 91d30fe..c853140 100644
--- a/internal/api/handlers_test.go
+++ b/internal/api/handlers_test.go
@@ -13,12 +13,12 @@ import (
"testing/fstest"
"time"
- "github.com/paul/kiss-media-player/internal"
- "github.com/paul/kiss-media-player/internal/auth"
- "github.com/paul/kiss-media-player/internal/clock"
- "github.com/paul/kiss-media-player/internal/model"
- "github.com/paul/kiss-media-player/internal/repository"
- "github.com/paul/kiss-media-player/internal/service"
+ "codeberg.org/snonux/play/internal"
+ "codeberg.org/snonux/play/internal/auth"
+ "codeberg.org/snonux/play/internal/clock"
+ "codeberg.org/snonux/play/internal/model"
+ "codeberg.org/snonux/play/internal/repository"
+ "codeberg.org/snonux/play/internal/service"
)
type memFS struct {
@@ -297,7 +297,7 @@ type staticHasher struct {
fixed string
}
-func (h *staticHasher) Hash(password string) (string, error) { return h.fixed, nil }
+func (h *staticHasher) Hash(password string) (string, error) { return h.fixed, nil }
func (h *staticHasher) Compare(hash, password string) error {
if hash == h.fixed && password == "correct" {
return nil
@@ -570,14 +570,14 @@ func TestServer_MediaList(t *testing.T) {
wantCode: http.StatusOK,
},
{
- name: "service error",
- listErr: errors.New("boom"),
+ name: "service error",
+ listErr: errors.New("boom"),
wantCode: http.StatusInternalServerError,
},
{
- name: "with query params",
- query: "?set_id=1&type=video&search=foo&tags=bar,baz&favorites=2&min_duration=10&max_duration=100&sort=name&limit=5&offset=10",
- filter: repository.MediaFilter{SetID: intPtr(1), Type: (*model.MediaType)(func() *string { s := "video"; return &s }()), Search: "foo", Tags: []string{"bar", "baz"}, Favorites: intPtr(2), MinDuration: floatPtr(10), MaxDuration: floatPtr(100), Sort: "name", Limit: 5, Offset: 10},
+ name: "with query params",
+ query: "?set_id=1&type=video&search=foo&tags=bar,baz&favorites=2&min_duration=10&max_duration=100&sort=name&limit=5&offset=10",
+ filter: repository.MediaFilter{SetID: intPtr(1), Type: (*model.MediaType)(func() *string { s := "video"; return &s }()), Search: "foo", Tags: []string{"bar", "baz"}, Favorites: intPtr(2), MinDuration: floatPtr(10), MaxDuration: floatPtr(100), Sort: "name", Limit: 5, Offset: 10},
listResult: []model.Media{},
wantCode: http.StatusOK,
},
@@ -613,12 +613,12 @@ func TestServer_MediaList(t *testing.T) {
func TestServer_MediaDetail(t *testing.T) {
tests := []struct {
- name string
- id string
- result *service.MediaDetail
- err error
- wantCode int
- wantMedia bool
+ name string
+ id string
+ result *service.MediaDetail
+ err error
+ wantCode int
+ wantMedia bool
}{
{"ok", "42", &service.MediaDetail{Media: &model.Media{ID: 42, FileName: "a.mp4"}}, nil, http.StatusOK, true},
{"invalid id", "abc", nil, nil, http.StatusBadRequest, false},
diff --git a/internal/api/middleware.go b/internal/api/middleware.go
index 5b99cc7..ee1d6c9 100644
--- a/internal/api/middleware.go
+++ b/internal/api/middleware.go
@@ -5,9 +5,9 @@ import (
"net/http"
"strings"
- "github.com/paul/kiss-media-player/internal/auth"
- "github.com/paul/kiss-media-player/internal/model"
- "github.com/paul/kiss-media-player/internal/repository"
+ "codeberg.org/snonux/play/internal/auth"
+ "codeberg.org/snonux/play/internal/model"
+ "codeberg.org/snonux/play/internal/repository"
)
type ctxKey int
diff --git a/internal/api/server.go b/internal/api/server.go
index 897add1..370313c 100644
--- a/internal/api/server.go
+++ b/internal/api/server.go
@@ -6,10 +6,10 @@ import (
"strconv"
"time"
- "github.com/paul/kiss-media-player/internal"
- "github.com/paul/kiss-media-player/internal/auth"
- "github.com/paul/kiss-media-player/internal/repository"
- "github.com/paul/kiss-media-player/internal/service"
+ "codeberg.org/snonux/play/internal"
+ "codeberg.org/snonux/play/internal/auth"
+ "codeberg.org/snonux/play/internal/repository"
+ "codeberg.org/snonux/play/internal/service"
)
// Server holds HTTP handlers and dependencies.