refactor: rename fake plugins to test plugins for clarity in integration tests

Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
Deluan 2025-12-26 13:39:53 -05:00
parent 06e6c09882
commit dd238e74fb
39 changed files with 124 additions and 124 deletions

View File

@ -29,9 +29,9 @@ var _ = Describe("ArtworkService", Ordered, func() {
tmpDir, err = os.MkdirTemp("", "artwork-test-*")
Expect(err).ToNot(HaveOccurred())
// Copy the fake-artwork plugin
srcPath := filepath.Join(testdataDir, "fake-artwork.wasm")
destPath := filepath.Join(tmpDir, "fake-artwork.wasm")
// Copy the test-artwork plugin
srcPath := filepath.Join(testdataDir, "test-artwork.wasm")
destPath := filepath.Join(tmpDir, "test-artwork.wasm")
data, err := os.ReadFile(srcPath)
Expect(err).ToNot(HaveOccurred())
err = os.WriteFile(destPath, data, 0600)
@ -64,7 +64,7 @@ var _ = Describe("ArtworkService", Ordered, func() {
Describe("Plugin Loading", func() {
It("should load plugin with artwork permission", func() {
manager.mu.RLock()
p, ok := manager.plugins["fake-artwork"]
p, ok := manager.plugins["test-artwork"]
manager.mu.RUnlock()
Expect(ok).To(BeTrue())
Expect(p.manifest.Permissions).ToNot(BeNil())
@ -85,7 +85,7 @@ var _ = Describe("ArtworkService", Ordered, func() {
callTestArtwork := func(ctx context.Context, artworkType, id string, size int32) (string, error) {
manager.mu.RLock()
p := manager.plugins["fake-artwork"]
p := manager.plugins["test-artwork"]
manager.mu.RUnlock()
instance, err := p.instance()

View File

@ -323,9 +323,9 @@ var _ = Describe("CacheService Integration", Ordered, func() {
tmpDir, err = os.MkdirTemp("", "cache-test-*")
Expect(err).ToNot(HaveOccurred())
// Copy the fake_cache_plugin
srcPath := filepath.Join(testdataDir, "fake_cache_plugin.wasm")
destPath := filepath.Join(tmpDir, "fake_cache_plugin.wasm")
// Copy the test-cache-plugin
srcPath := filepath.Join(testdataDir, "test-cache-plugin.wasm")
destPath := filepath.Join(tmpDir, "test-cache-plugin.wasm")
data, err := os.ReadFile(srcPath)
Expect(err).ToNot(HaveOccurred())
err = os.WriteFile(destPath, data, 0600)
@ -354,7 +354,7 @@ var _ = Describe("CacheService Integration", Ordered, func() {
Describe("Plugin Loading", func() {
It("should load plugin with cache permission", func() {
manager.mu.RLock()
p, ok := manager.plugins["fake_cache_plugin"]
p, ok := manager.plugins["test-cache-plugin"]
manager.mu.RUnlock()
Expect(ok).To(BeTrue())
Expect(p.manifest.Permissions).ToNot(BeNil())
@ -383,7 +383,7 @@ var _ = Describe("CacheService Integration", Ordered, func() {
callTestCache := func(ctx context.Context, input testCacheInput) (*testCacheOutput, error) {
manager.mu.RLock()
p := manager.plugins["fake_cache_plugin"]
p := manager.plugins["test-cache-plugin"]
manager.mu.RUnlock()
instance, err := p.instance()

View File

@ -31,9 +31,9 @@ var _ = Describe("SchedulerService", Ordered, func() {
tmpDir, err = os.MkdirTemp("", "scheduler-test-*")
Expect(err).ToNot(HaveOccurred())
// Copy the fake-scheduler plugin
srcPath := filepath.Join(testdataDir, "fake-scheduler.wasm")
destPath := filepath.Join(tmpDir, "fake-scheduler.wasm")
// Copy the test-scheduler plugin
srcPath := filepath.Join(testdataDir, "test-scheduler.wasm")
destPath := filepath.Join(tmpDir, "test-scheduler.wasm")
data, err := os.ReadFile(srcPath)
Expect(err).ToNot(HaveOccurred())
err = os.WriteFile(destPath, data, 0600)
@ -62,7 +62,7 @@ var _ = Describe("SchedulerService", Ordered, func() {
Expect(err).ToNot(HaveOccurred())
// Get scheduler service from plugin's closers and wrap it for testing
service := findSchedulerService(manager, "fake-scheduler")
service := findSchedulerService(manager, "test-scheduler")
Expect(service).ToNot(BeNil())
testService = &testableSchedulerService{schedulerServiceImpl: service}
testService.scheduler = mockSched
@ -83,11 +83,11 @@ var _ = Describe("SchedulerService", Ordered, func() {
Describe("Plugin Loading", func() {
It("should detect scheduler capability", func() {
names := manager.PluginNames(string(CapabilityScheduler))
Expect(names).To(ContainElement("fake-scheduler"))
Expect(names).To(ContainElement("test-scheduler"))
})
It("should register scheduler service for plugin", func() {
service := findSchedulerService(manager, "fake-scheduler")
service := findSchedulerService(manager, "test-scheduler")
Expect(service).ToNot(BeNil())
})
})
@ -241,7 +241,7 @@ var _ = Describe("SchedulerService", Ordered, func() {
// Get the plugin
manager.mu.RLock()
plugin, ok := manager.plugins["fake-scheduler"]
plugin, ok := manager.plugins["test-scheduler"]
manager.mu.RUnlock()
Expect(ok).To(BeTrue())
@ -278,10 +278,10 @@ var _ = Describe("SchedulerService", Ordered, func() {
Expect(mockSched.GetCallbackCount()).To(Equal(1)) // Only recurring task uses scheduler
Expect(mockTimers.GetTimerCount()).To(Equal(1)) // Only one-time task uses timer
err = manager.UnloadPlugin("fake-scheduler")
err = manager.UnloadPlugin("test-scheduler")
Expect(err).ToNot(HaveOccurred())
Expect(findSchedulerService(manager, "fake-scheduler")).To(BeNil())
Expect(findSchedulerService(manager, "test-scheduler")).To(BeNil())
Expect(mockSched.GetCallbackCount()).To(Equal(0)) // Recurring task removed
})
})

View File

@ -31,8 +31,8 @@ var _ = Describe("SubsonicAPI Host Function", Ordered, func() {
Expect(err).ToNot(HaveOccurred())
// Copy test plugin to temp dir
srcPath := filepath.Join(testdataDir, "fake-subsonicapi-plugin.wasm")
destPath := filepath.Join(tmpDir, "fake-subsonicapi-plugin.wasm")
srcPath := filepath.Join(testdataDir, "test-subsonicapi-plugin.wasm")
destPath := filepath.Join(tmpDir, "test-subsonicapi-plugin.wasm")
data, err := os.ReadFile(srcPath)
Expect(err).ToNot(HaveOccurred())
err = os.WriteFile(destPath, data, 0600)
@ -82,7 +82,7 @@ var _ = Describe("SubsonicAPI Host Function", Ordered, func() {
Describe("Plugin Loading", func() {
It("loads the plugin with SubsonicAPI permission", func() {
manager.mu.RLock()
plugin := manager.plugins["fake-subsonicapi-plugin"]
plugin := manager.plugins["test-subsonicapi-plugin"]
manager.mu.RUnlock()
Expect(plugin).ToNot(BeNil())
@ -90,11 +90,11 @@ var _ = Describe("SubsonicAPI Host Function", Ordered, func() {
It("has the correct manifest", func() {
manager.mu.RLock()
plugin := manager.plugins["fake-subsonicapi-plugin"]
plugin := manager.plugins["test-subsonicapi-plugin"]
manager.mu.RUnlock()
Expect(plugin).ToNot(BeNil())
Expect(plugin.manifest.Name).To(Equal("Fake SubsonicAPI Plugin"))
Expect(plugin.manifest.Name).To(Equal("Test SubsonicAPI Plugin"))
Expect(plugin.manifest.Permissions.Subsonicapi).ToNot(BeNil())
})
})
@ -104,7 +104,7 @@ var _ = Describe("SubsonicAPI Host Function", Ordered, func() {
BeforeEach(func() {
manager.mu.RLock()
plugin = manager.plugins["fake-subsonicapi-plugin"]
plugin = manager.plugins["test-subsonicapi-plugin"]
manager.mu.RUnlock()
Expect(plugin).ToNot(BeNil())
})
@ -139,7 +139,7 @@ var _ = Describe("SubsonicAPI Host Function", Ordered, func() {
// Verify the parameters were added
Expect(router.lastRequest).ToNot(BeNil())
query := router.lastRequest.URL.Query()
Expect(query.Get("c")).To(Equal("fake-subsonicapi-plugin"))
Expect(query.Get("c")).To(Equal("test-subsonicapi-plugin"))
Expect(query.Get("f")).To(Equal("json"))
Expect(query.Get("v")).To(Equal("1.16.1"))
Expect(query.Get("type")).To(Equal("newest"))

View File

@ -32,9 +32,9 @@ var _ = Describe("WebSocketService", Ordered, func() {
tmpDir, err = os.MkdirTemp("", "websocket-test-*")
Expect(err).ToNot(HaveOccurred())
// Copy the fake-websocket plugin
srcPath := filepath.Join(testdataDir, "fake-websocket.wasm")
destPath := filepath.Join(tmpDir, "fake-websocket.wasm")
// Copy the test-websocket plugin
srcPath := filepath.Join(testdataDir, "test-websocket.wasm")
destPath := filepath.Join(tmpDir, "test-websocket.wasm")
data, err := os.ReadFile(srcPath)
Expect(err).ToNot(HaveOccurred())
err = os.WriteFile(destPath, data, 0600)
@ -55,7 +55,7 @@ var _ = Describe("WebSocketService", Ordered, func() {
Expect(err).ToNot(HaveOccurred())
// Get WebSocket service from plugin's closers and wrap it for testing
service := findWebSocketService(manager, "fake-websocket")
service := findWebSocketService(manager, "test-websocket")
Expect(service).ToNot(BeNil())
testService = &testableWebSocketService{webSocketServiceImpl: service}
@ -73,11 +73,11 @@ var _ = Describe("WebSocketService", Ordered, func() {
Describe("Plugin Loading", func() {
It("should detect WebSocket capability", func() {
names := manager.PluginNames(string(CapabilityWebSocket))
Expect(names).To(ContainElement("fake-websocket"))
Expect(names).To(ContainElement("test-websocket"))
})
It("should register WebSocket service for plugin", func() {
service := findWebSocketService(manager, "fake-websocket")
service := findWebSocketService(manager, "test-websocket")
Expect(service).ToNot(BeNil())
})
})
@ -98,7 +98,7 @@ var _ = Describe("WebSocketService", Ordered, func() {
})
It("should allow hosts matching wildcard patterns", func() {
// fake-websocket manifest allows *.example.com
// test-websocket manifest allows *.example.com
// The pattern *.example.com matches any host ending with .example.com
ctx := context.Background()
allowed := testService.isHostAllowed("api.example.com")
@ -115,7 +115,7 @@ var _ = Describe("WebSocketService", Ordered, func() {
})
It("should allow exact host matches", func() {
// fake-websocket manifest allows echo.websocket.org
// test-websocket manifest allows echo.websocket.org
allowed := testService.isHostAllowed("echo.websocket.org")
Expect(allowed).To(BeTrue())
@ -125,7 +125,7 @@ var _ = Describe("WebSocketService", Ordered, func() {
It("should strip port before checking host", func() {
// Implementation strips port before matching against patterns
// fake-websocket manifest has "localhost:*" which matches "localhost"
// test-websocket manifest has "localhost:*" which matches "localhost"
// after port stripping
// Note: The port wildcard pattern isn't actually implemented, but
// since port is stripped, "localhost:*" is compared against "localhost"

View File

@ -17,16 +17,16 @@ var _ = Describe("Manager", Ordered, func() {
// Ensure plugin is loaded at the start (might have been unloaded by previous tests)
BeforeAll(func() {
ctx = GinkgoT().Context()
if _, ok := testManager.plugins["fake-metadata-agent"]; !ok {
err := testManager.LoadPlugin("fake-metadata-agent")
if _, ok := testManager.plugins["test-metadata-agent"]; !ok {
err := testManager.LoadPlugin("test-metadata-agent")
Expect(err).ToNot(HaveOccurred())
}
})
// Ensure plugin is restored after all tests in this block
AfterAll(func() {
if _, ok := testManager.plugins["fake-metadata-agent"]; !ok {
_ = testManager.LoadPlugin("fake-metadata-agent")
if _, ok := testManager.plugins["test-metadata-agent"]; !ok {
_ = testManager.LoadPlugin("test-metadata-agent")
}
})
@ -34,7 +34,7 @@ var _ = Describe("Manager", Ordered, func() {
It("auto-loads plugins from folder on Start", func() {
// Plugin is already loaded by testManager.Start() via discoverPlugins
names := testManager.PluginNames(string(CapabilityMetadataAgent))
Expect(names).To(ContainElement("fake-metadata-agent"))
Expect(names).To(ContainElement("test-metadata-agent"))
})
It("returns error when plugin file does not exist", func() {
@ -45,7 +45,7 @@ var _ = Describe("Manager", Ordered, func() {
It("returns error when plugin is already loaded", func() {
// Plugin was loaded on Start, try to load again
err := testManager.LoadPlugin("fake-metadata-agent")
err := testManager.LoadPlugin("test-metadata-agent")
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("already loaded"))
})
@ -69,20 +69,20 @@ var _ = Describe("Manager", Ordered, func() {
Describe("UnloadPlugin", func() {
It("removes a loaded plugin", func() {
// Plugin is already loaded from Start
err := testManager.UnloadPlugin("fake-metadata-agent")
err := testManager.UnloadPlugin("test-metadata-agent")
Expect(err).ToNot(HaveOccurred())
names := testManager.PluginNames(string(CapabilityMetadataAgent))
Expect(names).ToNot(ContainElement("fake-metadata-agent"))
Expect(names).ToNot(ContainElement("test-metadata-agent"))
})
It("can reload after unload", func() {
// Reload the plugin we just unloaded
err := testManager.LoadPlugin("fake-metadata-agent")
err := testManager.LoadPlugin("test-metadata-agent")
Expect(err).ToNot(HaveOccurred())
names := testManager.PluginNames(string(CapabilityMetadataAgent))
Expect(names).To(ContainElement("fake-metadata-agent"))
Expect(names).To(ContainElement("test-metadata-agent"))
})
It("returns error when plugin not found", func() {
@ -94,11 +94,11 @@ var _ = Describe("Manager", Ordered, func() {
Describe("ReloadPlugin", func() {
It("unloads and reloads a plugin", func() {
err := testManager.ReloadPlugin("fake-metadata-agent")
err := testManager.ReloadPlugin("test-metadata-agent")
Expect(err).ToNot(HaveOccurred())
names := testManager.PluginNames(string(CapabilityMetadataAgent))
Expect(names).To(ContainElement("fake-metadata-agent"))
Expect(names).To(ContainElement("test-metadata-agent"))
})
It("returns error when plugin not found", func() {
@ -111,9 +111,9 @@ var _ = Describe("Manager", Ordered, func() {
Describe("GetPluginInfo", func() {
It("returns information about all loaded plugins", func() {
info := testManager.GetPluginInfo()
Expect(info).To(HaveKey("fake-metadata-agent"))
Expect(info["fake-metadata-agent"].Name).To(Equal("Test Plugin"))
Expect(info["fake-metadata-agent"].Version).To(Equal("1.0.0"))
Expect(info).To(HaveKey("test-metadata-agent"))
Expect(info["test-metadata-agent"].Name).To(Equal("Test Plugin"))
Expect(info["test-metadata-agent"].Version).To(Equal("1.0.0"))
})
})
@ -129,7 +129,7 @@ var _ = Describe("Manager", Ordered, func() {
for i := range concurrency {
go func(i int) {
defer g.Done()
a, ok := testManager.LoadMediaAgent("fake-metadata-agent")
a, ok := testManager.LoadMediaAgent("test-metadata-agent")
Expect(ok).To(BeTrue())
agent := a.(agents.ArtistBiographyRetriever)
bio, err := agent.GetArtistBiography(ctx, fmt.Sprintf("artist-%d", i), fmt.Sprintf("Artist %d", i), "")

View File

@ -16,13 +16,13 @@ var _ = Describe("MetadataAgent", Ordered, func() {
ctx = GinkgoT().Context()
// Load the agent via shared manager
var ok bool
agent, ok = testManager.LoadMediaAgent("fake-metadata-agent")
agent, ok = testManager.LoadMediaAgent("test-metadata-agent")
Expect(ok).To(BeTrue())
})
Describe("AgentName", func() {
It("returns the plugin name", func() {
Expect(agent.AgentName()).To(Equal("fake-metadata-agent"))
Expect(agent.AgentName()).To(Equal("test-metadata-agent"))
})
})
@ -127,14 +127,14 @@ var _ = Describe("MetadataAgent error handling", Ordered, func() {
// Create manager with error injection config
errorManager, _ = createTestManager(map[string]map[string]string{
"fake-metadata-agent": {
"test-metadata-agent": {
"error": "simulated plugin error",
},
})
// Load the agent
var ok bool
errorAgent, ok = errorManager.LoadMediaAgent("fake-metadata-agent")
errorAgent, ok = errorManager.LoadMediaAgent("test-metadata-agent")
Expect(ok).To(BeTrue())
})

View File

@ -21,7 +21,7 @@ const testDataDir = "plugins/testdata"
// Shared test state initialized in BeforeSuite
var (
testdataDir string // Path to testdata folder with fake-metadata-agent.wasm
testdataDir string // Path to testdata folder with test-metadata-agent.wasm
tmpPluginsDir string // Temp directory for plugin tests that modify files
testManager *Manager
)
@ -46,10 +46,10 @@ func buildTestPlugins(t *testing.T, path string) {
}
// createTestManager creates a new plugin Manager with the given plugin config.
// It creates a temp directory, copies the fake-metadata-agent plugin, and starts the manager.
// It creates a temp directory, copies the test-metadata-agent plugin, and starts the manager.
// Returns the manager, temp directory path, and a cleanup function.
func createTestManager(pluginConfig map[string]map[string]string) (*Manager, string) {
return createTestManagerWithPlugins(pluginConfig, "fake-metadata-agent.wasm")
return createTestManagerWithPlugins(pluginConfig, "test-metadata-agent.wasm")
}
// createTestManagerWithPlugins creates a new plugin Manager with the given plugin config
@ -94,7 +94,7 @@ func createTestManagerWithPlugins(pluginConfig map[string]map[string]string, plu
}
var _ = BeforeSuite(func() {
// Get testdata directory (where fake-metadata-agent.wasm lives)
// Get testdata directory (where test-metadata-agent.wasm lives)
_, currentFile, _, ok := runtime.Caller(0)
Expect(ok).To(BeTrue())
testdataDir = filepath.Join(filepath.Dir(currentFile), "testdata")

View File

@ -25,11 +25,11 @@ var _ = Describe("ScrobblerPlugin", Ordered, func() {
// Add user to context for username extraction
ctx = request.WithUser(ctx, model.User{ID: "user-1", UserName: "testuser"})
// Load the scrobbler via a new manager with the fake-scrobbler plugin
scrobblerManager, _ = createTestManagerWithPlugins(nil, "fake-scrobbler.wasm")
// Load the scrobbler via a new manager with the test-scrobbler plugin
scrobblerManager, _ = createTestManagerWithPlugins(nil, "test-scrobbler.wasm")
var ok bool
s, ok = scrobblerManager.LoadScrobbler("fake-scrobbler")
s, ok = scrobblerManager.LoadScrobbler("test-scrobbler")
Expect(ok).To(BeTrue())
})
@ -39,7 +39,7 @@ var _ = Describe("ScrobblerPlugin", Ordered, func() {
})
It("returns false for a plugin without Scrobbler capability", func() {
_, ok := testManager.LoadScrobbler("fake-metadata-agent")
_, ok := testManager.LoadScrobbler("test-metadata-agent")
Expect(ok).To(BeFalse())
})
@ -57,10 +57,10 @@ var _ = Describe("ScrobblerPlugin", Ordered, func() {
It("returns false when plugin is configured to not authorize", func() {
manager, _ := createTestManagerWithPlugins(map[string]map[string]string{
"fake-scrobbler": {"authorized": "false"},
}, "fake-scrobbler.wasm")
"test-scrobbler": {"authorized": "false"},
}, "test-scrobbler.wasm")
sc, ok := manager.LoadScrobbler("fake-scrobbler")
sc, ok := manager.LoadScrobbler("test-scrobbler")
Expect(ok).To(BeTrue())
result := sc.IsAuthorized(ctx, "user-1")
@ -87,10 +87,10 @@ var _ = Describe("ScrobblerPlugin", Ordered, func() {
It("returns error when plugin returns error", func() {
manager, _ := createTestManagerWithPlugins(map[string]map[string]string{
"fake-scrobbler": {"error": "service unavailable", "error_type": "retry_later"},
}, "fake-scrobbler.wasm")
"test-scrobbler": {"error": "service unavailable", "error_type": "retry_later"},
}, "test-scrobbler.wasm")
sc, ok := manager.LoadScrobbler("fake-scrobbler")
sc, ok := manager.LoadScrobbler("test-scrobbler")
Expect(ok).To(BeTrue())
track := &model.MediaFile{ID: "track-1", Title: "Test Song"}
@ -122,10 +122,10 @@ var _ = Describe("ScrobblerPlugin", Ordered, func() {
It("returns error when plugin returns not_authorized error", func() {
manager, _ := createTestManagerWithPlugins(map[string]map[string]string{
"fake-scrobbler": {"error": "user not linked", "error_type": "not_authorized"},
}, "fake-scrobbler.wasm")
"test-scrobbler": {"error": "user not linked", "error_type": "not_authorized"},
}, "test-scrobbler.wasm")
sc, ok := manager.LoadScrobbler("fake-scrobbler")
sc, ok := manager.LoadScrobbler("test-scrobbler")
Expect(ok).To(BeTrue())
scrobble := scrobbler.Scrobble{
@ -139,10 +139,10 @@ var _ = Describe("ScrobblerPlugin", Ordered, func() {
It("returns error when plugin returns unrecoverable error", func() {
manager, _ := createTestManagerWithPlugins(map[string]map[string]string{
"fake-scrobbler": {"error": "track rejected", "error_type": "unrecoverable"},
}, "fake-scrobbler.wasm")
"test-scrobbler": {"error": "track rejected", "error_type": "unrecoverable"},
}, "test-scrobbler.wasm")
sc, ok := manager.LoadScrobbler("fake-scrobbler")
sc, ok := manager.LoadScrobbler("test-scrobbler")
Expect(ok).To(BeTrue())
scrobble := scrobbler.Scrobble{
@ -158,12 +158,12 @@ var _ = Describe("ScrobblerPlugin", Ordered, func() {
Describe("PluginNames", func() {
It("returns plugin names with Scrobbler capability", func() {
names := scrobblerManager.PluginNames("Scrobbler")
Expect(names).To(ContainElement("fake-scrobbler"))
Expect(names).To(ContainElement("test-scrobbler"))
})
It("does not return metadata agent plugins for Scrobbler capability", func() {
names := testManager.PluginNames("Scrobbler")
Expect(names).ToNot(ContainElement("fake-metadata-agent"))
Expect(names).ToNot(ContainElement("test-metadata-agent"))
})
})
})

View File

@ -1,4 +1,4 @@
# Build fake sample plugins used for testing
# Build test plugins used for integration testing
# Auto-discover all plugin folders (folders containing go.mod)
PLUGINS := $(patsubst %/go.mod,%,$(wildcard */go.mod))

View File

@ -1,5 +0,0 @@
module fake-cache
go 1.23
require github.com/extism/go-pdk v1.1.3

View File

@ -1,4 +1,4 @@
module fake-artwork
module test-artwork
go 1.23

View File

@ -1,5 +1,5 @@
// Fake Artwork plugin for Navidrome plugin system integration tests.
// Build with: tinygo build -o ../fake-artwork.wasm -target wasip1 -buildmode=c-shared .
// Test Artwork plugin for Navidrome plugin system integration tests.
// Build with: tinygo build -o ../test-artwork.wasm -target wasip1 -buildmode=c-shared .
package main
import (
@ -29,10 +29,10 @@ type ArtworkPermission struct {
//go:wasmexport nd_manifest
func ndManifest() int32 {
manifest := Manifest{
Name: "Fake Artwork",
Name: "Test Artwork",
Author: "Navidrome Test",
Version: "1.0.0",
Description: "A fake artwork plugin for integration testing",
Description: "A test artwork plugin for integration testing",
Permissions: &Permissions{
Artwork: &ArtworkPermission{
Reason: "For testing artwork URL generation",

View File

@ -0,0 +1,5 @@
module test-cache-plugin
go 1.23
require github.com/extism/go-pdk v1.1.3

View File

@ -1,5 +1,5 @@
// Fake Cache plugin for Navidrome plugin system integration tests.
// Build with: tinygo build -o ../fake_cache_plugin.wasm -target wasip1 -buildmode=c-shared .
// Test Cache plugin for Navidrome plugin system integration tests.
// Build with: tinygo build -o ../test-cache-plugin.wasm -target wasip1 -buildmode=c-shared .
package main
import (
@ -28,10 +28,10 @@ type CachePermission struct {
//go:wasmexport nd_manifest
func ndManifest() int32 {
manifest := Manifest{
Name: "Fake Cache Plugin",
Name: "Test Cache Plugin",
Author: "Navidrome Test",
Version: "1.0.0",
Description: "A fake cache plugin for integration testing",
Description: "A test cache plugin for integration testing",
Permissions: &Permissions{
Cache: &CachePermission{
Reason: "For testing cache operations",

View File

@ -1,4 +1,4 @@
module fake-scrobbler
module test-scheduler
go 1.23

View File

@ -1,5 +1,5 @@
// Fake scheduler plugin for Navidrome plugin system integration tests.
// Build with: tinygo build -o ../fake-scheduler.wasm -target wasip1 -buildmode=c-shared .
// Test scheduler plugin for Navidrome plugin system integration tests.
// Build with: tinygo build -o ../test-scheduler.wasm -target wasip1 -buildmode=c-shared .
package main
import (
@ -28,10 +28,10 @@ type SchedulerPermission struct {
//go:wasmexport nd_manifest
func ndManifest() int32 {
manifest := Manifest{
Name: "Fake Scheduler",
Name: "Test Scheduler",
Author: "Navidrome Test",
Version: "1.0.0",
Description: "A fake scheduler plugin for integration testing",
Description: "A test scheduler plugin for integration testing",
Permissions: &Permissions{
Scheduler: &SchedulerPermission{
Reason: "For testing scheduler callbacks",

View File

@ -1,4 +1,4 @@
module fake-scheduler
module test-scrobbler
go 1.23

View File

@ -1,5 +1,5 @@
// Fake scrobbler plugin for Navidrome plugin system integration tests.
// Build with: tinygo build -o ../fake-scrobbler.wasm -target wasip1 -buildmode=c-shared ./main.go
// Test scrobbler plugin for Navidrome plugin system integration tests.
// Build with: tinygo build -o ../test-scrobbler.wasm -target wasip1 -buildmode=c-shared ./main.go
package main
import (
@ -94,10 +94,10 @@ func checkAuthConfig() bool {
//go:wasmexport nd_manifest
func ndManifest() int32 {
manifest := Manifest{
Name: "Fake Scrobbler",
Name: "Test Scrobbler",
Author: "Navidrome Test",
Version: "1.0.0",
Description: "A fake scrobbler plugin for integration testing",
Description: "A test scrobbler plugin for integration testing",
}
out, err := json.Marshal(manifest)
if err != nil {

View File

@ -1,4 +1,4 @@
module fake-subsonicapi-plugin
module test-subsonicapi-plugin
go 1.24

View File

@ -1,5 +1,5 @@
// Test plugin for SubsonicAPI host function integration tests.
// Build with: tinygo build -o ../fake-subsonicapi-plugin.wasm -target wasip1 -buildmode=c-shared ./main.go
// Build with: tinygo build -o ../test-subsonicapi-plugin.wasm -target wasip1 -buildmode=c-shared ./main.go
package main
import (
@ -29,7 +29,7 @@ type SubsonicAPIPermission struct {
//go:wasmexport nd_manifest
func ndManifest() int32 {
manifest := Manifest{
Name: "Fake SubsonicAPI Plugin",
Name: "Test SubsonicAPI Plugin",
Author: "Navidrome Test",
Version: "1.0.0",
Description: "Test plugin for SubsonicAPI host function",

View File

@ -1,4 +1,4 @@
module fake-websocket
module test-websocket
go 1.23

View File

@ -1,5 +1,5 @@
// Fake WebSocket plugin for Navidrome plugin system integration tests.
// Build with: tinygo build -o ../fake-websocket.wasm -target wasip1 -buildmode=c-shared .
// Test WebSocket plugin for Navidrome plugin system integration tests.
// Build with: tinygo build -o ../test-websocket.wasm -target wasip1 -buildmode=c-shared .
package main
import (
@ -29,10 +29,10 @@ type WebSocketPermission struct {
//go:wasmexport nd_manifest
func ndManifest() int32 {
manifest := Manifest{
Name: "Fake WebSocket",
Name: "Test WebSocket",
Author: "Navidrome Test",
Version: "1.0.0",
Description: "A fake WebSocket plugin for integration testing",
Description: "A test WebSocket plugin for integration testing",
Permissions: &Permissions{
WebSocket: &WebSocketPermission{
Reason: "For testing WebSocket callbacks",

View File

@ -30,14 +30,14 @@ var _ = Describe("Watcher Integration", Ordered, func() {
manager, tmpDir = createTestManager(nil)
// Remove the auto-loaded plugin so tests can control loading
_ = manager.UnloadPlugin("fake-metadata-agent")
_ = os.Remove(filepath.Join(tmpDir, "fake-metadata-agent.wasm"))
_ = manager.UnloadPlugin("test-metadata-agent")
_ = os.Remove(filepath.Join(tmpDir, "test-metadata-agent.wasm"))
})
// Helper to copy test plugin into the temp folder
copyTestPlugin := func() {
srcPath := filepath.Join(testdataDir, "fake-metadata-agent.wasm")
destPath := filepath.Join(tmpDir, "fake-metadata-agent.wasm")
srcPath := filepath.Join(testdataDir, "test-metadata-agent.wasm")
destPath := filepath.Join(tmpDir, "test-metadata-agent.wasm")
data, err := os.ReadFile(srcPath)
Expect(err).ToNot(HaveOccurred())
err = os.WriteFile(destPath, data, 0600)
@ -49,32 +49,32 @@ var _ = Describe("Watcher Integration", Ordered, func() {
AfterEach(func() {
// Clean up: unload plugin if loaded, remove copied file
_ = manager.UnloadPlugin("fake-metadata-agent")
_ = os.Remove(filepath.Join(tmpDir, "fake-metadata-agent.wasm"))
_ = manager.UnloadPlugin("test-metadata-agent")
_ = os.Remove(filepath.Join(tmpDir, "test-metadata-agent.wasm"))
})
It("loads a plugin on CREATE event", func() {
copyTestPlugin()
manager.processPluginEvent("fake-metadata-agent", notify.Create)
Expect(manager.PluginNames(string(CapabilityMetadataAgent))).To(ContainElement("fake-metadata-agent"))
manager.processPluginEvent("test-metadata-agent", notify.Create)
Expect(manager.PluginNames(string(CapabilityMetadataAgent))).To(ContainElement("test-metadata-agent"))
})
It("reloads a plugin on WRITE event", func() {
copyTestPlugin()
err := manager.LoadPlugin("fake-metadata-agent")
err := manager.LoadPlugin("test-metadata-agent")
Expect(err).ToNot(HaveOccurred())
manager.processPluginEvent("fake-metadata-agent", notify.Write)
Expect(manager.PluginNames(string(CapabilityMetadataAgent))).To(ContainElement("fake-metadata-agent"))
manager.processPluginEvent("test-metadata-agent", notify.Write)
Expect(manager.PluginNames(string(CapabilityMetadataAgent))).To(ContainElement("test-metadata-agent"))
})
It("unloads a plugin on REMOVE event", func() {
copyTestPlugin()
err := manager.LoadPlugin("fake-metadata-agent")
err := manager.LoadPlugin("test-metadata-agent")
Expect(err).ToNot(HaveOccurred())
manager.processPluginEvent("fake-metadata-agent", notify.Remove)
Expect(manager.PluginNames(string(CapabilityMetadataAgent))).ToNot(ContainElement("fake-metadata-agent"))
manager.processPluginEvent("test-metadata-agent", notify.Remove)
Expect(manager.PluginNames(string(CapabilityMetadataAgent))).ToNot(ContainElement("test-metadata-agent"))
})
})