|
| 1 | +package service |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/langgenius/dify-plugin-daemon/pkg/entities/plugin_entities" |
| 7 | +) |
| 8 | + |
| 9 | +func TestUploadPluginPkg_CacheKeyFormat(t *testing.T) { |
| 10 | + tests := []struct { |
| 11 | + name string |
| 12 | + pluginUniqueIdentifier plugin_entities.PluginUniqueIdentifier |
| 13 | + expectedKey string |
| 14 | + }{ |
| 15 | + { |
| 16 | + name: "standard plugin identifier", |
| 17 | + pluginUniqueIdentifier: plugin_entities.PluginUniqueIdentifier("author/plugin@1.0.0"), |
| 18 | + expectedKey: "manually_uploaded:author/plugin@1.0.0", |
| 19 | + }, |
| 20 | + { |
| 21 | + name: "plugin with version hash", |
| 22 | + pluginUniqueIdentifier: plugin_entities.PluginUniqueIdentifier("author/plugin@abc123def456"), |
| 23 | + expectedKey: "manually_uploaded:author/plugin@abc123def456", |
| 24 | + }, |
| 25 | + { |
| 26 | + name: "plugin with special characters", |
| 27 | + pluginUniqueIdentifier: plugin_entities.PluginUniqueIdentifier("my-org/my-plugin@1.0.0-beta"), |
| 28 | + expectedKey: "manually_uploaded:my-org/my-plugin@1.0.0-beta", |
| 29 | + }, |
| 30 | + { |
| 31 | + name: "langgenius gemini plugin", |
| 32 | + pluginUniqueIdentifier: plugin_entities.PluginUniqueIdentifier("langgenius/gemini@0.7.17"), |
| 33 | + expectedKey: "manually_uploaded:langgenius/gemini@0.7.17", |
| 34 | + }, |
| 35 | + } |
| 36 | + |
| 37 | + for _, tt := range tests { |
| 38 | + t.Run(tt.name, func(t *testing.T) { |
| 39 | + cacheKey := "manually_uploaded:" + tt.pluginUniqueIdentifier.String() |
| 40 | + |
| 41 | + if cacheKey != tt.expectedKey { |
| 42 | + t.Errorf("cache key mismatch\n got: %s\nwant: %s", cacheKey, tt.expectedKey) |
| 43 | + } |
| 44 | + |
| 45 | + t.Logf("✓ Cache key format correct: %s", cacheKey) |
| 46 | + }) |
| 47 | + } |
| 48 | +} |
0 commit comments