mirror of
https://github.com/navidrome/navidrome.git
synced 2026-11-26 20:09:47 +01:00
refactor: multiple syntax updates for Go 1.26
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
parent
545a9ecc3c
commit
efe9291db0
51 changed files with 143 additions and 251 deletions
|
|
@ -37,8 +37,7 @@ var _ = Describe("KVStoreService", func() {
|
|||
conf.Server.DataFolder = conf.NewDir(tmpDir)
|
||||
|
||||
// Create service with 1KB limit for testing
|
||||
maxSize := "1KB"
|
||||
service, err = newKVStoreService(ctx, "test_plugin", &KVStorePermission{MaxSize: &maxSize})
|
||||
service, err = newKVStoreService(ctx, "test_plugin", &KVStorePermission{MaxSize: new("1KB")})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
})
|
||||
|
||||
|
|
@ -253,8 +252,7 @@ var _ = Describe("KVStoreService", func() {
|
|||
// Close and reopen the service (simulating restart)
|
||||
Expect(service.Close()).To(Succeed())
|
||||
|
||||
maxSize := "1KB"
|
||||
service2, err := newKVStoreService(ctx, "test_plugin", &KVStorePermission{MaxSize: &maxSize})
|
||||
service2, err := newKVStoreService(ctx, "test_plugin", &KVStorePermission{MaxSize: new("1KB")})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
defer service2.Close()
|
||||
|
||||
|
|
@ -452,8 +450,7 @@ var _ = Describe("KVStoreService", func() {
|
|||
closeCtx, closeCancel := context.WithCancel(ctx)
|
||||
defer closeCancel()
|
||||
|
||||
maxSize := "1KB"
|
||||
svc, err := newKVStoreService(closeCtx, "test_close_race", &KVStorePermission{MaxSize: &maxSize})
|
||||
svc, err := newKVStoreService(closeCtx, "test_close_race", &KVStorePermission{MaxSize: new("1KB")})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
// Insert an expired key so cleanup has work to do
|
||||
|
|
|
|||
|
|
@ -35,8 +35,7 @@ var _ = Describe("LibraryService", Ordered, func() {
|
|||
|
||||
Describe("GetLibrary", func() {
|
||||
It("should return library metadata without filesystem permission", func() {
|
||||
reason := "test"
|
||||
service = newLibraryService(ds, &LibraryPermission{Reason: &reason, Filesystem: false}, nil, true).(*libraryServiceImpl)
|
||||
service = newLibraryService(ds, &LibraryPermission{Reason: new("test"), Filesystem: false}, nil, true).(*libraryServiceImpl)
|
||||
|
||||
lib := &model.Library{
|
||||
ID: 1,
|
||||
|
|
@ -67,8 +66,7 @@ var _ = Describe("LibraryService", Ordered, func() {
|
|||
})
|
||||
|
||||
It("should return library metadata with filesystem permission", func() {
|
||||
reason := "test"
|
||||
service = newLibraryService(ds, &LibraryPermission{Reason: &reason, Filesystem: true}, nil, true).(*libraryServiceImpl)
|
||||
service = newLibraryService(ds, &LibraryPermission{Reason: new("test"), Filesystem: true}, nil, true).(*libraryServiceImpl)
|
||||
|
||||
lib := &model.Library{
|
||||
ID: 2,
|
||||
|
|
@ -93,8 +91,7 @@ var _ = Describe("LibraryService", Ordered, func() {
|
|||
})
|
||||
|
||||
It("should return error for non-existent library", func() {
|
||||
reason := "test"
|
||||
service = newLibraryService(ds, &LibraryPermission{Reason: &reason}, nil, true).(*libraryServiceImpl)
|
||||
service = newLibraryService(ds, &LibraryPermission{Reason: new("test")}, nil, true).(*libraryServiceImpl)
|
||||
|
||||
mockLibRepo := ds.Library(ctx).(*tests.MockLibraryRepo)
|
||||
mockLibRepo.SetData(model.Libraries{})
|
||||
|
|
@ -107,8 +104,7 @@ var _ = Describe("LibraryService", Ordered, func() {
|
|||
|
||||
Describe("GetAllLibraries", func() {
|
||||
It("should return all libraries without filesystem permission", func() {
|
||||
reason := "test"
|
||||
service = newLibraryService(ds, &LibraryPermission{Reason: &reason, Filesystem: false}, nil, true).(*libraryServiceImpl)
|
||||
service = newLibraryService(ds, &LibraryPermission{Reason: new("test"), Filesystem: false}, nil, true).(*libraryServiceImpl)
|
||||
|
||||
libs := model.Libraries{
|
||||
{ID: 1, Name: "Rock", Path: "/music/rock", TotalSongs: 100},
|
||||
|
|
@ -130,8 +126,7 @@ var _ = Describe("LibraryService", Ordered, func() {
|
|||
})
|
||||
|
||||
It("should return all libraries with filesystem permission", func() {
|
||||
reason := "test"
|
||||
service = newLibraryService(ds, &LibraryPermission{Reason: &reason, Filesystem: true}, nil, true).(*libraryServiceImpl)
|
||||
service = newLibraryService(ds, &LibraryPermission{Reason: new("test"), Filesystem: true}, nil, true).(*libraryServiceImpl)
|
||||
|
||||
libs := model.Libraries{
|
||||
{ID: 1, Name: "Rock", Path: "/music/rock", TotalSongs: 100},
|
||||
|
|
@ -152,10 +147,8 @@ var _ = Describe("LibraryService", Ordered, func() {
|
|||
})
|
||||
|
||||
Describe("Library Access Filtering", func() {
|
||||
It("should only return libraries in the allowed list", func() {
|
||||
reason := "test"
|
||||
// Only allow library ID 2
|
||||
service = newLibraryService(ds, &LibraryPermission{Reason: &reason, Filesystem: false}, []int{2}, false).(*libraryServiceImpl)
|
||||
It("should only return libraries in the allowed list", func() { // Only allow library ID 2
|
||||
service = newLibraryService(ds, &LibraryPermission{Reason: new("test"), Filesystem: false}, []int{2}, false).(*libraryServiceImpl)
|
||||
|
||||
libs := model.Libraries{
|
||||
{ID: 1, Name: "Rock", Path: "/music/rock", TotalSongs: 100},
|
||||
|
|
@ -173,10 +166,8 @@ var _ = Describe("LibraryService", Ordered, func() {
|
|||
Expect(results[0].Name).To(Equal("Jazz"))
|
||||
})
|
||||
|
||||
It("should return error when getting a library not in the allowed list", func() {
|
||||
reason := "test"
|
||||
// Only allow library ID 2
|
||||
service = newLibraryService(ds, &LibraryPermission{Reason: &reason, Filesystem: false}, []int{2}, false).(*libraryServiceImpl)
|
||||
It("should return error when getting a library not in the allowed list", func() { // Only allow library ID 2
|
||||
service = newLibraryService(ds, &LibraryPermission{Reason: new("test"), Filesystem: false}, []int{2}, false).(*libraryServiceImpl)
|
||||
|
||||
libs := model.Libraries{
|
||||
{ID: 1, Name: "Rock", Path: "/music/rock", TotalSongs: 100},
|
||||
|
|
@ -192,10 +183,8 @@ var _ = Describe("LibraryService", Ordered, func() {
|
|||
Expect(err.Error()).To(ContainSubstring("not accessible"))
|
||||
})
|
||||
|
||||
It("should allow access to a library in the allowed list", func() {
|
||||
reason := "test"
|
||||
// Only allow library ID 2
|
||||
service = newLibraryService(ds, &LibraryPermission{Reason: &reason, Filesystem: false}, []int{2}, false).(*libraryServiceImpl)
|
||||
It("should allow access to a library in the allowed list", func() { // Only allow library ID 2
|
||||
service = newLibraryService(ds, &LibraryPermission{Reason: new("test"), Filesystem: false}, []int{2}, false).(*libraryServiceImpl)
|
||||
|
||||
libs := model.Libraries{
|
||||
{ID: 1, Name: "Rock", Path: "/music/rock", TotalSongs: 100},
|
||||
|
|
@ -211,10 +200,8 @@ var _ = Describe("LibraryService", Ordered, func() {
|
|||
Expect(result.Name).To(Equal("Jazz"))
|
||||
})
|
||||
|
||||
It("should return empty list when no libraries are allowed and allLibraries is false", func() {
|
||||
reason := "test"
|
||||
// No libraries allowed
|
||||
service = newLibraryService(ds, &LibraryPermission{Reason: &reason, Filesystem: false}, []int{}, false).(*libraryServiceImpl)
|
||||
It("should return empty list when no libraries are allowed and allLibraries is false", func() { // No libraries allowed
|
||||
service = newLibraryService(ds, &LibraryPermission{Reason: new("test"), Filesystem: false}, []int{}, false).(*libraryServiceImpl)
|
||||
|
||||
libs := model.Libraries{
|
||||
{ID: 1, Name: "Rock", Path: "/music/rock", TotalSongs: 100},
|
||||
|
|
@ -229,10 +216,8 @@ var _ = Describe("LibraryService", Ordered, func() {
|
|||
Expect(results).To(HaveLen(0))
|
||||
})
|
||||
|
||||
It("should return all libraries when allLibraries is true regardless of allowed list", func() {
|
||||
reason := "test"
|
||||
// allLibraries=true should ignore the allowed list
|
||||
service = newLibraryService(ds, &LibraryPermission{Reason: &reason, Filesystem: false}, []int{1}, true).(*libraryServiceImpl)
|
||||
It("should return all libraries when allLibraries is true regardless of allowed list", func() { // allLibraries=true should ignore the allowed list
|
||||
service = newLibraryService(ds, &LibraryPermission{Reason: new("test"), Filesystem: false}, []int{1}, true).(*libraryServiceImpl)
|
||||
|
||||
libs := model.Libraries{
|
||||
{ID: 1, Name: "Rock", Path: "/music/rock", TotalSongs: 100},
|
||||
|
|
|
|||
|
|
@ -302,8 +302,7 @@ func (s *webSocketServiceImpl) readLoop(ctx context.Context, connectionID string
|
|||
if websocket.IsCloseError(err, websocket.CloseNormalClosure, websocket.CloseGoingAway, websocket.CloseNoStatusReceived) {
|
||||
closeCode := websocket.CloseNoStatusReceived
|
||||
closeReason := ""
|
||||
var ce *websocket.CloseError
|
||||
if errors.As(err, &ce) {
|
||||
if ce, ok := errors.AsType[*websocket.CloseError](err); ok {
|
||||
closeCode = ce.Code
|
||||
closeReason = ce.Text
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,11 +140,10 @@ var _ = Describe("Manifest", func() {
|
|||
})
|
||||
|
||||
It("returns true when threads feature has a reason", func() {
|
||||
reason := "Required for concurrent processing"
|
||||
m := &Manifest{
|
||||
Experimental: &Experimental{
|
||||
Threads: &ThreadsFeature{
|
||||
Reason: &reason,
|
||||
Reason: new("Required for concurrent processing"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,12 +135,11 @@ var _ = Describe("ndpPackage", func() {
|
|||
Describe("readManifest", func() {
|
||||
It("should read only the manifest without loading wasm", func() {
|
||||
ndpPath := filepath.Join(tmpDir, "test.ndp")
|
||||
desc := "A test plugin"
|
||||
manifest := &Manifest{
|
||||
Name: "Test Plugin",
|
||||
Author: "Test Author",
|
||||
Version: "1.0.0",
|
||||
Description: &desc,
|
||||
Description: new("A test plugin"),
|
||||
}
|
||||
wasmBytes := make([]byte, 1024*1024) // 1MB of zeros
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue