@@ -5,57 +5,9 @@ import (
55 "testing"
66
77 "github.com/langgenius/dify-plugin-daemon/internal/types/app"
8- "github.com/langgenius/dify-plugin-daemon/internal/types/models"
98 "github.com/langgenius/dify-plugin-daemon/pkg/entities/plugin_entities"
109)
1110
12- func TestInstallPluginResponseIncludesPrimaryTask (t * testing.T ) {
13- setupTestDB (t )
14-
15- identifier , err := plugin_entities .NewPluginUniqueIdentifier ("author/test-plugin:1.0.0@abcdef1234567890abcdef1234567890ab" )
16- if err != nil {
17- t .Fatalf ("failed to create plugin unique identifier: %v" , err )
18- }
19-
20- taskRegistry , err := createInstallTasks ([]string {"tenant-123" }, []models.InstallTaskPluginStatus {
21- {
22- PluginUniqueIdentifier : identifier ,
23- PluginID : identifier .PluginID (),
24- Status : models .InstallTaskStatusPending ,
25- Source : "marketplace" ,
26- },
27- })
28- if err != nil {
29- t .Fatalf ("failed to create install task: %v" , err )
30- }
31-
32- response := InstallPluginResponse {
33- AllInstalled : false ,
34- TaskID : taskRegistry .PrimaryID (),
35- Task : taskRegistry .PrimaryTask (),
36- }
37-
38- data , err := json .Marshal (response )
39- if err != nil {
40- t .Fatalf ("failed to marshal response: %v" , err )
41- }
42-
43- var decoded InstallPluginResponse
44- if err := json .Unmarshal (data , & decoded ); err != nil {
45- t .Fatalf ("failed to unmarshal response: %v" , err )
46- }
47-
48- if decoded .Task == nil {
49- t .Fatal ("expected response task to be present" )
50- }
51- if decoded .TaskID == "" {
52- t .Fatal ("expected response task_id to be present" )
53- }
54- if decoded .Task .ID != decoded .TaskID {
55- t .Fatalf ("task id mismatch: got %s, want %s" , decoded .Task .ID , decoded .TaskID )
56- }
57- }
58-
5911func TestUpgradePlugin (t * testing.T ) {
6012 originalIdentifier , err := plugin_entities .NewPluginUniqueIdentifier ("author/test-plugin:1.0.0@abcdef1234567890abcdef1234567890ab" )
6113 if err != nil {
@@ -72,32 +24,32 @@ func TestUpgradePlugin(t *testing.T) {
7224 }
7325
7426 tests := []struct {
75- name string
76- tenantId string
77- source string
78- meta map [string ]any
79- originalPluginUniqueIdentifier plugin_entities.PluginUniqueIdentifier
80- newPluginUniqueIdentifier plugin_entities.PluginUniqueIdentifier
81- wantSuccess bool
82- wantAllInstalled bool
83- wantTaskIDEmpty bool
27+ name string
28+ tenantId string
29+ source string
30+ meta map [string ]any
31+ originalPluginUniqueIdentifier plugin_entities.PluginUniqueIdentifier
32+ newPluginUniqueIdentifier plugin_entities.PluginUniqueIdentifier
33+ wantSuccess bool
34+ wantAllInstalled bool
35+ wantTaskIDEmpty bool
8436 }{
8537 {
8638 name : "same plugin identifiers" ,
8739 tenantId : "tenant-123" ,
8840 source : "test" ,
8941 meta : map [string ]any {},
90- originalPluginUniqueIdentifier : originalIdentifier ,
91- newPluginUniqueIdentifier : originalIdentifier ,
42+ originalPluginUniqueIdentifier : originalIdentifier ,
43+ newPluginUniqueIdentifier : originalIdentifier ,
9244 wantSuccess : false ,
9345 },
9446 {
9547 name : "different plugin identifiers" ,
9648 tenantId : "tenant-123" ,
9749 source : "test" ,
9850 meta : map [string ]any {},
99- originalPluginUniqueIdentifier : originalIdentifier ,
100- newPluginUniqueIdentifier : newIdentifier ,
51+ originalPluginUniqueIdentifier : originalIdentifier ,
52+ newPluginUniqueIdentifier : newIdentifier ,
10153 wantSuccess : false ,
10254 },
10355 }
0 commit comments