chore: ut
This commit is contained in:
903
backend/application/conversation/openapi_agent_run_test.go
Normal file
903
backend/application/conversation/openapi_agent_run_test.go
Normal file
@ -0,0 +1,903 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2025 coze-dev Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package conversation
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"go.uber.org/mock/gomock"
|
||||||
|
|
||||||
|
"github.com/coze-dev/coze-studio/backend/api/model/conversation/common"
|
||||||
|
"github.com/coze-dev/coze-studio/backend/api/model/conversation/run"
|
||||||
|
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/singleagent"
|
||||||
|
saEntity "github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/entity"
|
||||||
|
convEntity "github.com/coze-dev/coze-studio/backend/domain/conversation/conversation/entity"
|
||||||
|
openapiEntity "github.com/coze-dev/coze-studio/backend/domain/openauth/openapiauth/entity"
|
||||||
|
cmdEntity "github.com/coze-dev/coze-studio/backend/domain/shortcutcmd/entity"
|
||||||
|
uploadEntity "github.com/coze-dev/coze-studio/backend/domain/upload/entity"
|
||||||
|
uploadService "github.com/coze-dev/coze-studio/backend/domain/upload/service"
|
||||||
|
sseImpl "github.com/coze-dev/coze-studio/backend/infra/impl/sse"
|
||||||
|
mockSingleAgent "github.com/coze-dev/coze-studio/backend/internal/mock/domain/agent/singleagent"
|
||||||
|
mockAgentRun "github.com/coze-dev/coze-studio/backend/internal/mock/domain/conversation/agentrun"
|
||||||
|
mockConversation "github.com/coze-dev/coze-studio/backend/internal/mock/domain/conversation/conversation"
|
||||||
|
mockShortcut "github.com/coze-dev/coze-studio/backend/internal/mock/domain/shortcutcmd"
|
||||||
|
mockUpload "github.com/coze-dev/coze-studio/backend/internal/mock/domain/upload"
|
||||||
|
"github.com/coze-dev/coze-studio/backend/pkg/ctxcache"
|
||||||
|
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||||
|
"github.com/coze-dev/coze-studio/backend/types/consts"
|
||||||
|
)
|
||||||
|
|
||||||
|
func setupMocks(t *testing.T) (*OpenapiAgentRunApplication, *mockShortcut.MockShortcutCmd, *mockUpload.MockUploadService, *mockAgentRun.MockRun, *mockConversation.MockConversation, *mockSingleAgent.MockSingleAgent, *gomock.Controller) {
|
||||||
|
ctrl := gomock.NewController(t)
|
||||||
|
|
||||||
|
mockShortcutSvc := mockShortcut.NewMockShortcutCmd(ctrl)
|
||||||
|
mockUploadSvc := mockUpload.NewMockUploadService(ctrl)
|
||||||
|
mockAgentRunSvc := mockAgentRun.NewMockRun(ctrl)
|
||||||
|
mockConversationSvc := mockConversation.NewMockConversation(ctrl)
|
||||||
|
mockSingleAgentSvc := mockSingleAgent.NewMockSingleAgent(ctrl)
|
||||||
|
|
||||||
|
app := &OpenapiAgentRunApplication{
|
||||||
|
ShortcutDomainSVC: mockShortcutSvc,
|
||||||
|
UploaodDomainSVC: mockUploadSvc,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup ConversationSVC mocks
|
||||||
|
originalConversationSVC := ConversationSVC
|
||||||
|
ConversationSVC = &ConversationApplicationService{
|
||||||
|
AgentRunDomainSVC: mockAgentRunSvc,
|
||||||
|
ConversationDomainSVC: mockConversationSvc,
|
||||||
|
appContext: &ServiceComponents{
|
||||||
|
SingleAgentDomainSVC: mockSingleAgentSvc,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Cleanup(func() {
|
||||||
|
ConversationSVC = originalConversationSVC
|
||||||
|
ctrl.Finish()
|
||||||
|
})
|
||||||
|
|
||||||
|
return app, mockShortcutSvc, mockUploadSvc, mockAgentRunSvc, mockConversationSvc, mockSingleAgentSvc, ctrl
|
||||||
|
}
|
||||||
|
|
||||||
|
func createTestContext() context.Context {
|
||||||
|
ctx := context.Background()
|
||||||
|
ctx = ctxcache.Init(ctx)
|
||||||
|
apiKey := &openapiEntity.ApiKey{
|
||||||
|
UserID: 12345,
|
||||||
|
ConnectorID: consts.CozeConnectorID,
|
||||||
|
}
|
||||||
|
ctxcache.Store(ctx, consts.OpenapiAuthKeyInCtx, apiKey)
|
||||||
|
return ctx
|
||||||
|
}
|
||||||
|
|
||||||
|
func createTestRequest() *run.ChatV3Request {
|
||||||
|
return &run.ChatV3Request{
|
||||||
|
BotID: 67890,
|
||||||
|
ConversationID: ptr.Of(int64(11111)),
|
||||||
|
User: "test-user",
|
||||||
|
AdditionalMessages: []*run.EnterMessage{
|
||||||
|
{
|
||||||
|
Role: "user",
|
||||||
|
Content: "Hello, world!",
|
||||||
|
ContentType: run.ContentTypeText,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func createTestRequestWithMultipleMessages() *run.ChatV3Request {
|
||||||
|
return &run.ChatV3Request{
|
||||||
|
BotID: 67890,
|
||||||
|
ConversationID: ptr.Of(int64(11111)),
|
||||||
|
User: "test-user",
|
||||||
|
AdditionalMessages: []*run.EnterMessage{
|
||||||
|
{
|
||||||
|
Role: "user",
|
||||||
|
Content: "Hello, I need help with something.",
|
||||||
|
ContentType: run.ContentTypeText,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Role: "assistant",
|
||||||
|
Content: "Sure, I'd be happy to help! What do you need assistance with?",
|
||||||
|
ContentType: run.ContentTypeText,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Role: "user",
|
||||||
|
Content: `{"type": "image", "url": "https://example.com/image.jpg"}`,
|
||||||
|
ContentType: run.ContentTypeImage,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Role: "user",
|
||||||
|
Content: `{"type": "file", "name": "document.pdf", "url": "https://example.com/doc.pdf"}`,
|
||||||
|
ContentType: run.ContentTypeFile,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func createTestRequestWithAssistantOnly() *run.ChatV3Request {
|
||||||
|
return &run.ChatV3Request{
|
||||||
|
BotID: 67890,
|
||||||
|
ConversationID: ptr.Of(int64(11111)),
|
||||||
|
User: "test-user",
|
||||||
|
AdditionalMessages: []*run.EnterMessage{
|
||||||
|
{
|
||||||
|
Role: "assistant",
|
||||||
|
Content: "I'm here to help you with any questions you might have.",
|
||||||
|
ContentType: run.ContentTypeText, // assistant role only supports text content type
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOpenapiAgentRun_Success(t *testing.T) {
|
||||||
|
app, _, _, mockAgentRun, mockConversation, mockSingleAgent, _ := setupMocks(t)
|
||||||
|
ctx := createTestContext()
|
||||||
|
req := createTestRequest()
|
||||||
|
|
||||||
|
// Mock agent check
|
||||||
|
mockAgent := &saEntity.SingleAgent{
|
||||||
|
SingleAgent: &singleagent.SingleAgent{
|
||||||
|
AgentID: 67890,
|
||||||
|
SpaceID: 54321,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
mockSingleAgent.EXPECT().ObtainAgentByIdentity(ctx, gomock.Any()).Return(mockAgent, nil)
|
||||||
|
|
||||||
|
// Mock conversation check
|
||||||
|
mockConv := &convEntity.Conversation{
|
||||||
|
ID: 11111,
|
||||||
|
CreatorID: 12345,
|
||||||
|
SectionID: 98765,
|
||||||
|
}
|
||||||
|
mockConversation.EXPECT().GetByID(ctx, int64(11111)).Return(mockConv, nil)
|
||||||
|
|
||||||
|
// Mock agent run failure to avoid pullStream complexity
|
||||||
|
mockAgentRun.EXPECT().AgentRun(ctx, gomock.Any()).Return(nil, errors.New("mock stream error"))
|
||||||
|
|
||||||
|
err := app.OpenapiAgentRun(ctx, &sseImpl.SSenderImpl{}, req)
|
||||||
|
|
||||||
|
assert.Error(t, err)
|
||||||
|
assert.Contains(t, err.Error(), "mock stream error")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOpenapiAgentRun_CheckAgentError(t *testing.T) {
|
||||||
|
app, _, _, _, _, mockSingleAgent, _ := setupMocks(t)
|
||||||
|
ctx := createTestContext()
|
||||||
|
req := createTestRequest()
|
||||||
|
|
||||||
|
// Mock agent check failure
|
||||||
|
mockSingleAgent.EXPECT().ObtainAgentByIdentity(ctx, gomock.Any()).Return(nil, errors.New("agent not found"))
|
||||||
|
|
||||||
|
err := app.OpenapiAgentRun(ctx, &sseImpl.SSenderImpl{}, req)
|
||||||
|
|
||||||
|
assert.Error(t, err)
|
||||||
|
assert.Contains(t, err.Error(), "agent not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOpenapiAgentRun_AgentNotExists(t *testing.T) {
|
||||||
|
app, _, _, _, _, mockSingleAgent, _ := setupMocks(t)
|
||||||
|
ctx := createTestContext()
|
||||||
|
req := createTestRequest()
|
||||||
|
|
||||||
|
// Mock agent check returns nil (agent not exists)
|
||||||
|
mockSingleAgent.EXPECT().ObtainAgentByIdentity(ctx, gomock.Any()).Return(nil, nil)
|
||||||
|
|
||||||
|
err := app.OpenapiAgentRun(ctx, &sseImpl.SSenderImpl{}, req)
|
||||||
|
|
||||||
|
assert.Error(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOpenapiAgentRun_CheckConversationError(t *testing.T) {
|
||||||
|
app, _, _, _, mockConversation, mockSingleAgent, _ := setupMocks(t)
|
||||||
|
ctx := createTestContext()
|
||||||
|
req := createTestRequest()
|
||||||
|
|
||||||
|
// Mock agent check success
|
||||||
|
mockAgent := &saEntity.SingleAgent{
|
||||||
|
SingleAgent: &singleagent.SingleAgent{
|
||||||
|
AgentID: 67890,
|
||||||
|
SpaceID: 54321,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
mockSingleAgent.EXPECT().ObtainAgentByIdentity(ctx, gomock.Any()).Return(mockAgent, nil)
|
||||||
|
|
||||||
|
// Mock conversation check failure
|
||||||
|
mockConversation.EXPECT().GetByID(ctx, int64(11111)).Return(nil, errors.New("conversation not found"))
|
||||||
|
|
||||||
|
err := app.OpenapiAgentRun(ctx, &sseImpl.SSenderImpl{}, req)
|
||||||
|
|
||||||
|
assert.Error(t, err)
|
||||||
|
assert.Contains(t, err.Error(), "conversation not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOpenapiAgentRun_ConversationPermissionError(t *testing.T) {
|
||||||
|
app, _, _, _, mockConversation, mockSingleAgent, _ := setupMocks(t)
|
||||||
|
ctx := createTestContext()
|
||||||
|
req := createTestRequest()
|
||||||
|
|
||||||
|
// Mock agent check success
|
||||||
|
mockAgent := &saEntity.SingleAgent{
|
||||||
|
SingleAgent: &singleagent.SingleAgent{
|
||||||
|
AgentID: 67890,
|
||||||
|
SpaceID: 54321,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
mockSingleAgent.EXPECT().ObtainAgentByIdentity(ctx, gomock.Any()).Return(mockAgent, nil)
|
||||||
|
|
||||||
|
// Mock conversation with different creator
|
||||||
|
mockConv := &convEntity.Conversation{
|
||||||
|
ID: 11111,
|
||||||
|
CreatorID: 99999, // Different from user ID (12345)
|
||||||
|
SectionID: 98765,
|
||||||
|
}
|
||||||
|
mockConversation.EXPECT().GetByID(ctx, int64(11111)).Return(mockConv, nil)
|
||||||
|
|
||||||
|
err := app.OpenapiAgentRun(ctx, &sseImpl.SSenderImpl{}, req)
|
||||||
|
|
||||||
|
assert.Error(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOpenapiAgentRun_CreateNewConversation(t *testing.T) {
|
||||||
|
app, _, _, mockAgentRun, mockConversation, mockSingleAgent, _ := setupMocks(t)
|
||||||
|
ctx := createTestContext()
|
||||||
|
req := createTestRequest()
|
||||||
|
req.ConversationID = ptr.Of(int64(0)) // No conversation ID
|
||||||
|
|
||||||
|
// Mock agent check success
|
||||||
|
mockAgent := &saEntity.SingleAgent{
|
||||||
|
SingleAgent: &singleagent.SingleAgent{
|
||||||
|
AgentID: 67890,
|
||||||
|
SpaceID: 54321,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
mockSingleAgent.EXPECT().ObtainAgentByIdentity(ctx, gomock.Any()).Return(mockAgent, nil)
|
||||||
|
|
||||||
|
// Mock create new conversation
|
||||||
|
mockConv := &convEntity.Conversation{
|
||||||
|
ID: 22222,
|
||||||
|
CreatorID: 12345,
|
||||||
|
SectionID: 98765,
|
||||||
|
}
|
||||||
|
mockConversation.EXPECT().Create(ctx, gomock.Any()).DoAndReturn(func(ctx context.Context, meta *convEntity.CreateMeta) (*convEntity.Conversation, error) {
|
||||||
|
assert.Equal(t, int64(67890), meta.AgentID)
|
||||||
|
assert.Equal(t, int64(12345), meta.UserID)
|
||||||
|
assert.Equal(t, common.Scene_SceneOpenApi, meta.Scene)
|
||||||
|
return mockConv, nil
|
||||||
|
})
|
||||||
|
|
||||||
|
// Mock agent run failure to avoid pullStream complexity
|
||||||
|
mockAgentRun.EXPECT().AgentRun(ctx, gomock.Any()).Return(nil, errors.New("mock stream error"))
|
||||||
|
|
||||||
|
err := app.OpenapiAgentRun(ctx, &sseImpl.SSenderImpl{}, req)
|
||||||
|
|
||||||
|
assert.Error(t, err)
|
||||||
|
assert.Equal(t, int64(22222), *req.ConversationID) // Should be updated
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOpenapiAgentRun_AgentRunError(t *testing.T) {
|
||||||
|
app, _, _, mockAgentRun, mockConversation, mockSingleAgent, _ := setupMocks(t)
|
||||||
|
ctx := createTestContext()
|
||||||
|
req := createTestRequest()
|
||||||
|
|
||||||
|
// Mock agent check success
|
||||||
|
mockAgent := &saEntity.SingleAgent{
|
||||||
|
SingleAgent: &singleagent.SingleAgent{
|
||||||
|
AgentID: 67890,
|
||||||
|
SpaceID: 54321,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
mockSingleAgent.EXPECT().ObtainAgentByIdentity(ctx, gomock.Any()).Return(mockAgent, nil)
|
||||||
|
|
||||||
|
// Mock conversation check success
|
||||||
|
mockConv := &convEntity.Conversation{
|
||||||
|
ID: 11111,
|
||||||
|
CreatorID: 12345,
|
||||||
|
SectionID: 98765,
|
||||||
|
}
|
||||||
|
mockConversation.EXPECT().GetByID(ctx, int64(11111)).Return(mockConv, nil)
|
||||||
|
|
||||||
|
// Mock agent run failure
|
||||||
|
mockAgentRun.EXPECT().AgentRun(ctx, gomock.Any()).Return(nil, errors.New("agent run failed"))
|
||||||
|
|
||||||
|
err := app.OpenapiAgentRun(ctx, &sseImpl.SSenderImpl{}, req)
|
||||||
|
|
||||||
|
assert.Error(t, err)
|
||||||
|
assert.Contains(t, err.Error(), "agent run failed")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOpenapiAgentRun_WithShortcutCommand(t *testing.T) {
|
||||||
|
app, mockShortcut, _, mockAgentRun, mockConversation, mockSingleAgent, _ := setupMocks(t)
|
||||||
|
ctx := createTestContext()
|
||||||
|
req := createTestRequest()
|
||||||
|
req.ShortcutCommand = &run.ShortcutCommandDetail{
|
||||||
|
CommandID: 123,
|
||||||
|
Parameters: map[string]string{"param1": "value1"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mock agent check success
|
||||||
|
mockAgent := &saEntity.SingleAgent{
|
||||||
|
SingleAgent: &singleagent.SingleAgent{
|
||||||
|
AgentID: 67890,
|
||||||
|
SpaceID: 54321,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
mockSingleAgent.EXPECT().ObtainAgentByIdentity(ctx, gomock.Any()).Return(mockAgent, nil)
|
||||||
|
|
||||||
|
// Mock conversation check success
|
||||||
|
mockConv := &convEntity.Conversation{
|
||||||
|
ID: 11111,
|
||||||
|
CreatorID: 12345,
|
||||||
|
SectionID: 98765,
|
||||||
|
}
|
||||||
|
mockConversation.EXPECT().GetByID(ctx, int64(11111)).Return(mockConv, nil)
|
||||||
|
|
||||||
|
// Mock shortcut command
|
||||||
|
mockCmd := &cmdEntity.ShortcutCmd{
|
||||||
|
ID: 123,
|
||||||
|
PluginID: 456,
|
||||||
|
PluginToolName: "test-tool",
|
||||||
|
PluginToolID: 789,
|
||||||
|
ToolType: 1,
|
||||||
|
}
|
||||||
|
mockShortcut.EXPECT().GetByCmdID(ctx, int64(123), int32(0)).Return(mockCmd, nil)
|
||||||
|
|
||||||
|
// Mock agent run failure to avoid pullStream complexity
|
||||||
|
mockAgentRun.EXPECT().AgentRun(ctx, gomock.Any()).Return(nil, errors.New("mock stream error"))
|
||||||
|
|
||||||
|
err := app.OpenapiAgentRun(ctx, &sseImpl.SSenderImpl{}, req)
|
||||||
|
|
||||||
|
assert.Error(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOpenapiAgentRun_WithMultipleMessages(t *testing.T) {
|
||||||
|
app, _, _, mockAgentRun, mockConversation, mockSingleAgent, _ := setupMocks(t)
|
||||||
|
ctx := createTestContext()
|
||||||
|
req := createTestRequestWithMultipleMessages()
|
||||||
|
|
||||||
|
// Mock agent check success
|
||||||
|
mockAgent := &saEntity.SingleAgent{
|
||||||
|
SingleAgent: &singleagent.SingleAgent{
|
||||||
|
AgentID: 67890,
|
||||||
|
SpaceID: 54321,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
mockSingleAgent.EXPECT().ObtainAgentByIdentity(ctx, gomock.Any()).Return(mockAgent, nil)
|
||||||
|
|
||||||
|
// Mock conversation check success
|
||||||
|
mockConv := &convEntity.Conversation{
|
||||||
|
ID: 11111,
|
||||||
|
CreatorID: 12345,
|
||||||
|
SectionID: 98765,
|
||||||
|
}
|
||||||
|
mockConversation.EXPECT().GetByID(ctx, int64(11111)).Return(mockConv, nil)
|
||||||
|
|
||||||
|
// Mock agent run failure to avoid pullStream complexity
|
||||||
|
mockAgentRun.EXPECT().AgentRun(ctx, gomock.Any()).Return(nil, errors.New("mock stream error"))
|
||||||
|
|
||||||
|
err := app.OpenapiAgentRun(ctx, &sseImpl.SSenderImpl{}, req)
|
||||||
|
|
||||||
|
assert.Error(t, err)
|
||||||
|
assert.Contains(t, err.Error(), "mock stream error")
|
||||||
|
|
||||||
|
// Verify that the request contains multiple messages with different roles and content types
|
||||||
|
assert.Len(t, req.AdditionalMessages, 4)
|
||||||
|
assert.Equal(t, "user", req.AdditionalMessages[0].Role)
|
||||||
|
assert.Equal(t, run.ContentTypeText, req.AdditionalMessages[0].ContentType)
|
||||||
|
assert.Equal(t, "assistant", req.AdditionalMessages[1].Role)
|
||||||
|
assert.Equal(t, run.ContentTypeText, req.AdditionalMessages[1].ContentType)
|
||||||
|
assert.Equal(t, "user", req.AdditionalMessages[2].Role)
|
||||||
|
assert.Equal(t, run.ContentTypeImage, req.AdditionalMessages[2].ContentType)
|
||||||
|
assert.Equal(t, "user", req.AdditionalMessages[3].Role)
|
||||||
|
assert.Equal(t, run.ContentTypeFile, req.AdditionalMessages[3].ContentType)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOpenapiAgentRun_WithAssistantMessage(t *testing.T) {
|
||||||
|
app, _, _, mockAgentRun, mockConversation, mockSingleAgent, _ := setupMocks(t)
|
||||||
|
ctx := createTestContext()
|
||||||
|
req := createTestRequestWithAssistantOnly()
|
||||||
|
|
||||||
|
// Mock agent check success
|
||||||
|
mockAgent := &saEntity.SingleAgent{
|
||||||
|
SingleAgent: &singleagent.SingleAgent{
|
||||||
|
AgentID: 67890,
|
||||||
|
SpaceID: 54321,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
mockSingleAgent.EXPECT().ObtainAgentByIdentity(ctx, gomock.Any()).Return(mockAgent, nil)
|
||||||
|
|
||||||
|
// Mock conversation check success
|
||||||
|
mockConv := &convEntity.Conversation{
|
||||||
|
ID: 11111,
|
||||||
|
CreatorID: 12345,
|
||||||
|
SectionID: 98765,
|
||||||
|
}
|
||||||
|
mockConversation.EXPECT().GetByID(ctx, int64(11111)).Return(mockConv, nil)
|
||||||
|
|
||||||
|
// Mock agent run failure to avoid pullStream complexity
|
||||||
|
mockAgentRun.EXPECT().AgentRun(ctx, gomock.Any()).Return(nil, errors.New("mock stream error"))
|
||||||
|
|
||||||
|
err := app.OpenapiAgentRun(ctx, &sseImpl.SSenderImpl{}, req)
|
||||||
|
|
||||||
|
assert.Error(t, err)
|
||||||
|
assert.Contains(t, err.Error(), "mock stream error")
|
||||||
|
|
||||||
|
// Verify that the assistant message only supports text content type
|
||||||
|
assert.Len(t, req.AdditionalMessages, 1)
|
||||||
|
assert.Equal(t, "assistant", req.AdditionalMessages[0].Role)
|
||||||
|
assert.Equal(t, run.ContentTypeText, req.AdditionalMessages[0].ContentType)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOpenapiAgentRun_WithMixedContentTypes(t *testing.T) {
|
||||||
|
app, _, _, mockAgentRun, mockConversation, mockSingleAgent, _ := setupMocks(t)
|
||||||
|
ctx := createTestContext()
|
||||||
|
|
||||||
|
// Create request with various content types for user role
|
||||||
|
req := &run.ChatV3Request{
|
||||||
|
BotID: 67890,
|
||||||
|
ConversationID: ptr.Of(int64(11111)),
|
||||||
|
User: "test-user",
|
||||||
|
AdditionalMessages: []*run.EnterMessage{
|
||||||
|
{
|
||||||
|
Role: "user",
|
||||||
|
Content: "Here's a text message",
|
||||||
|
ContentType: run.ContentTypeText,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Role: "user",
|
||||||
|
Content: `{"type": "audio", "url": "https://example.com/audio.mp3"}`,
|
||||||
|
ContentType: run.ContentTypeAudio,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Role: "user",
|
||||||
|
Content: `{"type": "video", "url": "https://example.com/video.mp4"}`,
|
||||||
|
ContentType: run.ContentTypeVideo,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Role: "assistant",
|
||||||
|
Content: "I can only respond with text content.",
|
||||||
|
ContentType: run.ContentTypeText, // assistant must use text
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Role: "user",
|
||||||
|
Content: `{"type": "link", "url": "https://example.com"}`,
|
||||||
|
ContentType: run.ContentTypeLink,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mock agent check success
|
||||||
|
mockAgent := &saEntity.SingleAgent{
|
||||||
|
SingleAgent: &singleagent.SingleAgent{
|
||||||
|
AgentID: 67890,
|
||||||
|
SpaceID: 54321,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
mockSingleAgent.EXPECT().ObtainAgentByIdentity(ctx, gomock.Any()).Return(mockAgent, nil)
|
||||||
|
|
||||||
|
// Mock conversation check success
|
||||||
|
mockConv := &convEntity.Conversation{
|
||||||
|
ID: 11111,
|
||||||
|
CreatorID: 12345,
|
||||||
|
SectionID: 98765,
|
||||||
|
}
|
||||||
|
mockConversation.EXPECT().GetByID(ctx, int64(11111)).Return(mockConv, nil)
|
||||||
|
|
||||||
|
// Mock agent run failure to avoid pullStream complexity
|
||||||
|
mockAgentRun.EXPECT().AgentRun(ctx, gomock.Any()).Return(nil, errors.New("mock stream error"))
|
||||||
|
|
||||||
|
err := app.OpenapiAgentRun(ctx, &sseImpl.SSenderImpl{}, req)
|
||||||
|
|
||||||
|
assert.Error(t, err)
|
||||||
|
assert.Contains(t, err.Error(), "mock stream error")
|
||||||
|
|
||||||
|
// Verify various content types are preserved
|
||||||
|
assert.Len(t, req.AdditionalMessages, 5)
|
||||||
|
|
||||||
|
// Check user messages with different content types
|
||||||
|
assert.Equal(t, "user", req.AdditionalMessages[0].Role)
|
||||||
|
assert.Equal(t, run.ContentTypeText, req.AdditionalMessages[0].ContentType)
|
||||||
|
|
||||||
|
assert.Equal(t, "user", req.AdditionalMessages[1].Role)
|
||||||
|
assert.Equal(t, run.ContentTypeAudio, req.AdditionalMessages[1].ContentType)
|
||||||
|
|
||||||
|
assert.Equal(t, "user", req.AdditionalMessages[2].Role)
|
||||||
|
assert.Equal(t, run.ContentTypeVideo, req.AdditionalMessages[2].ContentType)
|
||||||
|
|
||||||
|
// Check assistant message (must be text)
|
||||||
|
assert.Equal(t, "assistant", req.AdditionalMessages[3].Role)
|
||||||
|
assert.Equal(t, run.ContentTypeText, req.AdditionalMessages[3].ContentType)
|
||||||
|
|
||||||
|
assert.Equal(t, "user", req.AdditionalMessages[4].Role)
|
||||||
|
assert.Equal(t, run.ContentTypeLink, req.AdditionalMessages[4].ContentType)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOpenapiAgentRun_ParseAdditionalMessages_InvalidRole(t *testing.T) {
|
||||||
|
app, _, _, _, mockConversation, mockSingleAgent, _ := setupMocks(t)
|
||||||
|
ctx := createTestContext()
|
||||||
|
|
||||||
|
// Create request with invalid role
|
||||||
|
req := &run.ChatV3Request{
|
||||||
|
BotID: 67890,
|
||||||
|
ConversationID: ptr.Of(int64(11111)),
|
||||||
|
User: "test-user",
|
||||||
|
AdditionalMessages: []*run.EnterMessage{
|
||||||
|
{
|
||||||
|
Role: "system", // Invalid role
|
||||||
|
Content: "System message",
|
||||||
|
ContentType: run.ContentTypeText,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mock agent check success
|
||||||
|
mockAgent := &saEntity.SingleAgent{
|
||||||
|
SingleAgent: &singleagent.SingleAgent{
|
||||||
|
AgentID: 67890,
|
||||||
|
SpaceID: 54321,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
mockSingleAgent.EXPECT().ObtainAgentByIdentity(ctx, gomock.Any()).Return(mockAgent, nil)
|
||||||
|
|
||||||
|
// Mock conversation check success to reach parseAdditionalMessages
|
||||||
|
mockConv := &convEntity.Conversation{
|
||||||
|
ID: 11111,
|
||||||
|
CreatorID: 12345,
|
||||||
|
SectionID: 98765,
|
||||||
|
}
|
||||||
|
mockConversation.EXPECT().GetByID(ctx, int64(11111)).Return(mockConv, nil)
|
||||||
|
|
||||||
|
err := app.OpenapiAgentRun(ctx, &sseImpl.SSenderImpl{}, req)
|
||||||
|
|
||||||
|
assert.Error(t, err)
|
||||||
|
assert.Contains(t, err.Error(), "additional message role only support user and assistant")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func TestOpenapiAgentRun_ParseAdditionalMessages_InvalidType(t *testing.T) {
|
||||||
|
app, _, _, _, mockConversation, mockSingleAgent, _ := setupMocks(t)
|
||||||
|
ctx := createTestContext()
|
||||||
|
|
||||||
|
// Create request with invalid message type
|
||||||
|
invalidType := "invalid_type"
|
||||||
|
req := &run.ChatV3Request{
|
||||||
|
BotID: 67890,
|
||||||
|
ConversationID: ptr.Of(int64(11111)),
|
||||||
|
User: "test-user",
|
||||||
|
AdditionalMessages: []*run.EnterMessage{
|
||||||
|
{
|
||||||
|
Role: "user",
|
||||||
|
Content: "Test message",
|
||||||
|
ContentType: run.ContentTypeText,
|
||||||
|
Type: &invalidType, // Invalid type
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mock agent check success
|
||||||
|
mockAgent := &saEntity.SingleAgent{
|
||||||
|
SingleAgent: &singleagent.SingleAgent{
|
||||||
|
AgentID: 67890,
|
||||||
|
SpaceID: 54321,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
mockSingleAgent.EXPECT().ObtainAgentByIdentity(ctx, gomock.Any()).Return(mockAgent, nil)
|
||||||
|
|
||||||
|
// Mock conversation check success to reach parseAdditionalMessages
|
||||||
|
mockConv := &convEntity.Conversation{
|
||||||
|
ID: 11111,
|
||||||
|
CreatorID: 12345,
|
||||||
|
SectionID: 98765,
|
||||||
|
}
|
||||||
|
mockConversation.EXPECT().GetByID(ctx, int64(11111)).Return(mockConv, nil)
|
||||||
|
|
||||||
|
err := app.OpenapiAgentRun(ctx, &sseImpl.SSenderImpl{}, req)
|
||||||
|
|
||||||
|
assert.Error(t, err)
|
||||||
|
assert.Contains(t, err.Error(), "additional message type only support question and answer now")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOpenapiAgentRun_ParseAdditionalMessages_AnswerWithNonTextContent(t *testing.T) {
|
||||||
|
app, _, _, _, mockConversation, mockSingleAgent, _ := setupMocks(t)
|
||||||
|
ctx := createTestContext()
|
||||||
|
|
||||||
|
// Create request with answer type but non-text content
|
||||||
|
answerType := "answer"
|
||||||
|
req := &run.ChatV3Request{
|
||||||
|
BotID: 67890,
|
||||||
|
ConversationID: ptr.Of(int64(11111)),
|
||||||
|
User: "test-user",
|
||||||
|
AdditionalMessages: []*run.EnterMessage{
|
||||||
|
{
|
||||||
|
Role: "assistant",
|
||||||
|
Content: `[{"type": "image", "file_url": "https://example.com/image.jpg"}]`,
|
||||||
|
ContentType: run.ContentTypeMixApi, // object_string
|
||||||
|
Type: &answerType,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mock agent check success
|
||||||
|
mockAgent := &saEntity.SingleAgent{
|
||||||
|
SingleAgent: &singleagent.SingleAgent{
|
||||||
|
AgentID: 67890,
|
||||||
|
SpaceID: 54321,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
mockSingleAgent.EXPECT().ObtainAgentByIdentity(ctx, gomock.Any()).Return(mockAgent, nil)
|
||||||
|
|
||||||
|
// Mock conversation check success to reach parseAdditionalMessages
|
||||||
|
mockConv := &convEntity.Conversation{
|
||||||
|
ID: 11111,
|
||||||
|
CreatorID: 12345,
|
||||||
|
SectionID: 98765,
|
||||||
|
}
|
||||||
|
mockConversation.EXPECT().GetByID(ctx, int64(11111)).Return(mockConv, nil)
|
||||||
|
|
||||||
|
err := app.OpenapiAgentRun(ctx, &sseImpl.SSenderImpl{}, req)
|
||||||
|
|
||||||
|
assert.Error(t, err)
|
||||||
|
assert.Contains(t, err.Error(), "answer messages only support text content")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOpenapiAgentRun_ParseAdditionalMessages_MixApiWithFileURL(t *testing.T) {
|
||||||
|
app, _, _, mockAgentRun, mockConversation, mockSingleAgent, _ := setupMocks(t)
|
||||||
|
ctx := createTestContext()
|
||||||
|
|
||||||
|
// Create request with object_string content type and file URL
|
||||||
|
req := &run.ChatV3Request{
|
||||||
|
BotID: 67890,
|
||||||
|
ConversationID: ptr.Of(int64(11111)),
|
||||||
|
User: "test-user",
|
||||||
|
AdditionalMessages: []*run.EnterMessage{
|
||||||
|
{
|
||||||
|
Role: "user",
|
||||||
|
Content: `[{"type": "text", "text": "Here's an image:"}, {"type": "image", "file_url": "https://example.com/image.jpg"}]`,
|
||||||
|
ContentType: run.ContentTypeMixApi,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mock agent check success
|
||||||
|
mockAgent := &saEntity.SingleAgent{
|
||||||
|
SingleAgent: &singleagent.SingleAgent{
|
||||||
|
AgentID: 67890,
|
||||||
|
SpaceID: 54321,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
mockSingleAgent.EXPECT().ObtainAgentByIdentity(ctx, gomock.Any()).Return(mockAgent, nil)
|
||||||
|
|
||||||
|
// Mock conversation check success
|
||||||
|
mockConv := &convEntity.Conversation{
|
||||||
|
ID: 11111,
|
||||||
|
CreatorID: 12345,
|
||||||
|
SectionID: 98765,
|
||||||
|
}
|
||||||
|
mockConversation.EXPECT().GetByID(ctx, int64(11111)).Return(mockConv, nil)
|
||||||
|
|
||||||
|
// Mock agent run failure to avoid pullStream complexity
|
||||||
|
mockAgentRun.EXPECT().AgentRun(ctx, gomock.Any()).Return(nil, errors.New("mock stream error"))
|
||||||
|
|
||||||
|
err := app.OpenapiAgentRun(ctx, &sseImpl.SSenderImpl{}, req)
|
||||||
|
|
||||||
|
assert.Error(t, err)
|
||||||
|
assert.Contains(t, err.Error(), "mock stream error")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOpenapiAgentRun_ParseAdditionalMessages_MixApiWithFileID(t *testing.T) {
|
||||||
|
app, _, mockUpload, mockAgentRun, mockConversation, mockSingleAgent, _ := setupMocks(t)
|
||||||
|
ctx := createTestContext()
|
||||||
|
|
||||||
|
// Create request with object_string content type and file ID
|
||||||
|
req := &run.ChatV3Request{
|
||||||
|
BotID: 67890,
|
||||||
|
ConversationID: ptr.Of(int64(11111)),
|
||||||
|
User: "test-user",
|
||||||
|
AdditionalMessages: []*run.EnterMessage{
|
||||||
|
{
|
||||||
|
Role: "user",
|
||||||
|
Content: `[{"type": "file", "file_id": "12345"}]`,
|
||||||
|
ContentType: run.ContentTypeMixApi,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mock agent check success
|
||||||
|
mockAgent := &saEntity.SingleAgent{
|
||||||
|
SingleAgent: &singleagent.SingleAgent{
|
||||||
|
AgentID: 67890,
|
||||||
|
SpaceID: 54321,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
mockSingleAgent.EXPECT().ObtainAgentByIdentity(ctx, gomock.Any()).Return(mockAgent, nil)
|
||||||
|
|
||||||
|
// Mock conversation check success
|
||||||
|
mockConv := &convEntity.Conversation{
|
||||||
|
ID: 11111,
|
||||||
|
CreatorID: 12345,
|
||||||
|
SectionID: 98765,
|
||||||
|
}
|
||||||
|
mockConversation.EXPECT().GetByID(ctx, int64(11111)).Return(mockConv, nil)
|
||||||
|
|
||||||
|
// Mock upload service to return file info
|
||||||
|
mockUpload.EXPECT().GetFile(ctx, gomock.Any()).DoAndReturn(func(ctx context.Context, req *uploadService.GetFileRequest) (*uploadService.GetFileResponse, error) {
|
||||||
|
assert.Equal(t, int64(12345), req.ID)
|
||||||
|
return &uploadService.GetFileResponse{
|
||||||
|
File: &uploadEntity.File{
|
||||||
|
Url: "https://example.com/file.pdf",
|
||||||
|
TosURI: "tos://bucket/file.pdf",
|
||||||
|
},
|
||||||
|
}, nil
|
||||||
|
})
|
||||||
|
|
||||||
|
// Mock agent run failure to avoid pullStream complexity
|
||||||
|
mockAgentRun.EXPECT().AgentRun(ctx, gomock.Any()).Return(nil, errors.New("mock stream error"))
|
||||||
|
|
||||||
|
err := app.OpenapiAgentRun(ctx, &sseImpl.SSenderImpl{}, req)
|
||||||
|
|
||||||
|
assert.Error(t, err)
|
||||||
|
assert.Contains(t, err.Error(), "mock stream error")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOpenapiAgentRun_ParseAdditionalMessages_FileIDError(t *testing.T) {
|
||||||
|
app, _, mockUpload, _, mockConversation, mockSingleAgent, _ := setupMocks(t)
|
||||||
|
ctx := createTestContext()
|
||||||
|
|
||||||
|
// Create request with object_string content type and file ID that will fail
|
||||||
|
req := &run.ChatV3Request{
|
||||||
|
BotID: 67890,
|
||||||
|
ConversationID: ptr.Of(int64(11111)),
|
||||||
|
User: "test-user",
|
||||||
|
AdditionalMessages: []*run.EnterMessage{
|
||||||
|
{
|
||||||
|
Role: "user",
|
||||||
|
Content: `[{"type": "file", "file_id": "99999"}]`,
|
||||||
|
ContentType: run.ContentTypeMixApi,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mock agent check success
|
||||||
|
mockAgent := &saEntity.SingleAgent{
|
||||||
|
SingleAgent: &singleagent.SingleAgent{
|
||||||
|
AgentID: 67890,
|
||||||
|
SpaceID: 54321,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
mockSingleAgent.EXPECT().ObtainAgentByIdentity(ctx, gomock.Any()).Return(mockAgent, nil)
|
||||||
|
|
||||||
|
// Mock conversation check success
|
||||||
|
mockConv := &convEntity.Conversation{
|
||||||
|
ID: 11111,
|
||||||
|
CreatorID: 12345,
|
||||||
|
SectionID: 98765,
|
||||||
|
}
|
||||||
|
mockConversation.EXPECT().GetByID(ctx, int64(11111)).Return(mockConv, nil)
|
||||||
|
|
||||||
|
// Mock upload service to return error
|
||||||
|
mockUpload.EXPECT().GetFile(ctx, gomock.Any()).Return(nil, errors.New("file not found"))
|
||||||
|
|
||||||
|
err := app.OpenapiAgentRun(ctx, &sseImpl.SSenderImpl{}, req)
|
||||||
|
|
||||||
|
assert.Error(t, err)
|
||||||
|
assert.Contains(t, err.Error(), "file not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOpenapiAgentRun_ParseAdditionalMessages_EmptyContent(t *testing.T) {
|
||||||
|
app, _, _, mockAgentRun, mockConversation, mockSingleAgent, _ := setupMocks(t)
|
||||||
|
ctx := createTestContext()
|
||||||
|
|
||||||
|
// Create request with empty text content (should be skipped)
|
||||||
|
req := &run.ChatV3Request{
|
||||||
|
BotID: 67890,
|
||||||
|
ConversationID: ptr.Of(int64(11111)),
|
||||||
|
User: "test-user",
|
||||||
|
AdditionalMessages: []*run.EnterMessage{
|
||||||
|
{
|
||||||
|
Role: "user",
|
||||||
|
Content: "", // Empty content
|
||||||
|
ContentType: run.ContentTypeText,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Role: "user",
|
||||||
|
Content: "Valid content",
|
||||||
|
ContentType: run.ContentTypeText,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mock agent check success
|
||||||
|
mockAgent := &saEntity.SingleAgent{
|
||||||
|
SingleAgent: &singleagent.SingleAgent{
|
||||||
|
AgentID: 67890,
|
||||||
|
SpaceID: 54321,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
mockSingleAgent.EXPECT().ObtainAgentByIdentity(ctx, gomock.Any()).Return(mockAgent, nil)
|
||||||
|
|
||||||
|
// Mock conversation check success
|
||||||
|
mockConv := &convEntity.Conversation{
|
||||||
|
ID: 11111,
|
||||||
|
CreatorID: 12345,
|
||||||
|
SectionID: 98765,
|
||||||
|
}
|
||||||
|
mockConversation.EXPECT().GetByID(ctx, int64(11111)).Return(mockConv, nil)
|
||||||
|
|
||||||
|
// Mock agent run failure to avoid pullStream complexity
|
||||||
|
mockAgentRun.EXPECT().AgentRun(ctx, gomock.Any()).Return(nil, errors.New("mock stream error"))
|
||||||
|
|
||||||
|
err := app.OpenapiAgentRun(ctx, &sseImpl.SSenderImpl{}, req)
|
||||||
|
|
||||||
|
assert.Error(t, err)
|
||||||
|
assert.Contains(t, err.Error(), "mock stream error")
|
||||||
|
|
||||||
|
// Verify that only the non-empty message is included
|
||||||
|
assert.Len(t, req.AdditionalMessages, 2) // Original request still has 2 messages
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOpenapiAgentRun_ParseAdditionalMessages_NilMessage(t *testing.T) {
|
||||||
|
app, _, _, mockAgentRun, mockConversation, mockSingleAgent, _ := setupMocks(t)
|
||||||
|
ctx := createTestContext()
|
||||||
|
|
||||||
|
// Create request with empty content message (should be skipped)
|
||||||
|
req := &run.ChatV3Request{
|
||||||
|
BotID: 67890,
|
||||||
|
ConversationID: ptr.Of(int64(11111)),
|
||||||
|
User: "test-user",
|
||||||
|
AdditionalMessages: []*run.EnterMessage{
|
||||||
|
{
|
||||||
|
Role: "user",
|
||||||
|
Content: "", // Empty content message
|
||||||
|
ContentType: run.ContentTypeText,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Role: "user",
|
||||||
|
Content: "Valid content",
|
||||||
|
ContentType: run.ContentTypeText,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mock agent check success
|
||||||
|
mockAgent := &saEntity.SingleAgent{
|
||||||
|
SingleAgent: &singleagent.SingleAgent{
|
||||||
|
AgentID: 67890,
|
||||||
|
SpaceID: 54321,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
mockSingleAgent.EXPECT().ObtainAgentByIdentity(ctx, gomock.Any()).Return(mockAgent, nil)
|
||||||
|
|
||||||
|
// Mock conversation check success
|
||||||
|
mockConv := &convEntity.Conversation{
|
||||||
|
ID: 11111,
|
||||||
|
CreatorID: 12345,
|
||||||
|
SectionID: 98765,
|
||||||
|
}
|
||||||
|
mockConversation.EXPECT().GetByID(ctx, int64(11111)).Return(mockConv, nil)
|
||||||
|
|
||||||
|
// Mock agent run failure to avoid pullStream complexity
|
||||||
|
mockAgentRun.EXPECT().AgentRun(ctx, gomock.Any()).Return(nil, errors.New("mock stream error"))
|
||||||
|
|
||||||
|
err := app.OpenapiAgentRun(ctx, &sseImpl.SSenderImpl{}, req)
|
||||||
|
|
||||||
|
assert.Error(t, err)
|
||||||
|
assert.Contains(t, err.Error(), "mock stream error")
|
||||||
|
}
|
||||||
@ -25,6 +25,7 @@ import (
|
|||||||
"github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/entity"
|
"github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/entity"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:generate mockgen -destination ../../../../internal/mock/domain/agent/singleagent/single_agent_mock.go --package singleagent -source single_agent.go
|
||||||
type SingleAgent interface {
|
type SingleAgent interface {
|
||||||
// draft agent
|
// draft agent
|
||||||
CreateSingleAgentDraft(ctx context.Context, creatorID int64, draft *entity.SingleAgent) (agentID int64, err error)
|
CreateSingleAgentDraft(ctx context.Context, creatorID int64, draft *entity.SingleAgent) (agentID int64, err error)
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import (
|
|||||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/agentrun/entity"
|
"github.com/coze-dev/coze-studio/backend/domain/conversation/agentrun/entity"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:generate mockgen -destination ../../../../internal/mock/domain/conversation/agentrun/agent_run_mock.go --package agentrun -source agent_run.go
|
||||||
type Run interface {
|
type Run interface {
|
||||||
AgentRun(ctx context.Context, req *entity.AgentRunMeta) (*schema.StreamReader[*entity.AgentRunResponse], error)
|
AgentRun(ctx context.Context, req *entity.AgentRunMeta) (*schema.StreamReader[*entity.AgentRunResponse], error)
|
||||||
Delete(ctx context.Context, runID []int64) error
|
Delete(ctx context.Context, runID []int64) error
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import (
|
|||||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/conversation/entity"
|
"github.com/coze-dev/coze-studio/backend/domain/conversation/conversation/entity"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:generate mockgen -destination ../../../../internal/mock/domain/conversation/conversation/conversation_mock.go --package conversation -source conversation.go
|
||||||
type Conversation interface {
|
type Conversation interface {
|
||||||
Create(ctx context.Context, req *entity.CreateMeta) (*entity.Conversation, error)
|
Create(ctx context.Context, req *entity.CreateMeta) (*entity.Conversation, error)
|
||||||
GetByID(ctx context.Context, id int64) (*entity.Conversation, error)
|
GetByID(ctx context.Context, id int64) (*entity.Conversation, error)
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import (
|
|||||||
"github.com/coze-dev/coze-studio/backend/domain/shortcutcmd/entity"
|
"github.com/coze-dev/coze-studio/backend/domain/shortcutcmd/entity"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:generate mockgen -destination ../../../internal/mock/domain/shortcutcmd/shortcut_cmd_mock.go --package shortcutcmd -source shortcut_cmd.go
|
||||||
type ShortcutCmd interface {
|
type ShortcutCmd interface {
|
||||||
ListCMD(ctx context.Context, lm *entity.ListMeta) ([]*entity.ShortcutCmd, error)
|
ListCMD(ctx context.Context, lm *entity.ListMeta) ([]*entity.ShortcutCmd, error)
|
||||||
CreateCMD(ctx context.Context, shortcut *entity.ShortcutCmd) (*entity.ShortcutCmd, error)
|
CreateCMD(ctx context.Context, shortcut *entity.ShortcutCmd) (*entity.ShortcutCmd, error)
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import (
|
|||||||
"github.com/coze-dev/coze-studio/backend/domain/upload/entity"
|
"github.com/coze-dev/coze-studio/backend/domain/upload/entity"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:generate mockgen -destination ../../../internal/mock/domain/upload/upload_service_mock.go --package upload -source interface.go
|
||||||
type UploadService interface {
|
type UploadService interface {
|
||||||
UploadFile(ctx context.Context, req *UploadFileRequest) (resp *UploadFileResponse, err error)
|
UploadFile(ctx context.Context, req *UploadFileRequest) (resp *UploadFileResponse, err error)
|
||||||
UploadFiles(ctx context.Context, req *UploadFilesRequest) (resp *UploadFilesResponse, err error)
|
UploadFiles(ctx context.Context, req *UploadFilesRequest) (resp *UploadFilesResponse, err error)
|
||||||
|
|||||||
@ -0,0 +1,355 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2025 coze-dev Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Code generated by MockGen. DO NOT EDIT.
|
||||||
|
// Source: domain/agent/singleagent/service/single_agent.go
|
||||||
|
//
|
||||||
|
// Generated by this command:
|
||||||
|
//
|
||||||
|
// mockgen -destination internal/mock/domain/agent/singleagent/single_agent_mock.go --package mock -source domain/agent/singleagent/service/single_agent.go
|
||||||
|
//
|
||||||
|
|
||||||
|
// Package mock is a generated GoMock package.
|
||||||
|
package mock
|
||||||
|
|
||||||
|
import (
|
||||||
|
context "context"
|
||||||
|
reflect "reflect"
|
||||||
|
|
||||||
|
schema "github.com/cloudwego/eino/schema"
|
||||||
|
playground "github.com/coze-dev/coze-studio/backend/api/model/playground"
|
||||||
|
entity "github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/entity"
|
||||||
|
gomock "go.uber.org/mock/gomock"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MockSingleAgent is a mock of SingleAgent interface.
|
||||||
|
type MockSingleAgent struct {
|
||||||
|
ctrl *gomock.Controller
|
||||||
|
recorder *MockSingleAgentMockRecorder
|
||||||
|
isgomock struct{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MockSingleAgentMockRecorder is the mock recorder for MockSingleAgent.
|
||||||
|
type MockSingleAgentMockRecorder struct {
|
||||||
|
mock *MockSingleAgent
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewMockSingleAgent creates a new mock instance.
|
||||||
|
func NewMockSingleAgent(ctrl *gomock.Controller) *MockSingleAgent {
|
||||||
|
mock := &MockSingleAgent{ctrl: ctrl}
|
||||||
|
mock.recorder = &MockSingleAgentMockRecorder{mock}
|
||||||
|
return mock
|
||||||
|
}
|
||||||
|
|
||||||
|
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||||
|
func (m *MockSingleAgent) EXPECT() *MockSingleAgentMockRecorder {
|
||||||
|
return m.recorder
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateSingleAgent mocks base method.
|
||||||
|
func (m *MockSingleAgent) CreateSingleAgent(ctx context.Context, connectorID int64, version string, e *entity.SingleAgent) (int64, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "CreateSingleAgent", ctx, connectorID, version, e)
|
||||||
|
ret0, _ := ret[0].(int64)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateSingleAgent indicates an expected call of CreateSingleAgent.
|
||||||
|
func (mr *MockSingleAgentMockRecorder) CreateSingleAgent(ctx, connectorID, version, e any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateSingleAgent", reflect.TypeOf((*MockSingleAgent)(nil).CreateSingleAgent), ctx, connectorID, version, e)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateSingleAgentDraft mocks base method.
|
||||||
|
func (m *MockSingleAgent) CreateSingleAgentDraft(ctx context.Context, creatorID int64, draft *entity.SingleAgent) (int64, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "CreateSingleAgentDraft", ctx, creatorID, draft)
|
||||||
|
ret0, _ := ret[0].(int64)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateSingleAgentDraft indicates an expected call of CreateSingleAgentDraft.
|
||||||
|
func (mr *MockSingleAgentMockRecorder) CreateSingleAgentDraft(ctx, creatorID, draft any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateSingleAgentDraft", reflect.TypeOf((*MockSingleAgent)(nil).CreateSingleAgentDraft), ctx, creatorID, draft)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateSingleAgentDraftWithID mocks base method.
|
||||||
|
func (m *MockSingleAgent) CreateSingleAgentDraftWithID(ctx context.Context, creatorID, agentID int64, draft *entity.SingleAgent) (int64, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "CreateSingleAgentDraftWithID", ctx, creatorID, agentID, draft)
|
||||||
|
ret0, _ := ret[0].(int64)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateSingleAgentDraftWithID indicates an expected call of CreateSingleAgentDraftWithID.
|
||||||
|
func (mr *MockSingleAgentMockRecorder) CreateSingleAgentDraftWithID(ctx, creatorID, agentID, draft any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateSingleAgentDraftWithID", reflect.TypeOf((*MockSingleAgent)(nil).CreateSingleAgentDraftWithID), ctx, creatorID, agentID, draft)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteAgentDraft mocks base method.
|
||||||
|
func (m *MockSingleAgent) DeleteAgentDraft(ctx context.Context, spaceID, agentID int64) error {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "DeleteAgentDraft", ctx, spaceID, agentID)
|
||||||
|
ret0, _ := ret[0].(error)
|
||||||
|
return ret0
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteAgentDraft indicates an expected call of DeleteAgentDraft.
|
||||||
|
func (mr *MockSingleAgentMockRecorder) DeleteAgentDraft(ctx, spaceID, agentID any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteAgentDraft", reflect.TypeOf((*MockSingleAgent)(nil).DeleteAgentDraft), ctx, spaceID, agentID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DuplicateInMemory mocks base method.
|
||||||
|
func (m *MockSingleAgent) DuplicateInMemory(ctx context.Context, req *entity.DuplicateInfo) (*entity.SingleAgent, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "DuplicateInMemory", ctx, req)
|
||||||
|
ret0, _ := ret[0].(*entity.SingleAgent)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// DuplicateInMemory indicates an expected call of DuplicateInMemory.
|
||||||
|
func (mr *MockSingleAgentMockRecorder) DuplicateInMemory(ctx, req any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DuplicateInMemory", reflect.TypeOf((*MockSingleAgent)(nil).DuplicateInMemory), ctx, req)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAgentDraftDisplayInfo mocks base method.
|
||||||
|
func (m *MockSingleAgent) GetAgentDraftDisplayInfo(ctx context.Context, userID, agentID int64) (*entity.AgentDraftDisplayInfo, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "GetAgentDraftDisplayInfo", ctx, userID, agentID)
|
||||||
|
ret0, _ := ret[0].(*entity.AgentDraftDisplayInfo)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAgentDraftDisplayInfo indicates an expected call of GetAgentDraftDisplayInfo.
|
||||||
|
func (mr *MockSingleAgentMockRecorder) GetAgentDraftDisplayInfo(ctx, userID, agentID any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAgentDraftDisplayInfo", reflect.TypeOf((*MockSingleAgent)(nil).GetAgentDraftDisplayInfo), ctx, userID, agentID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAgentPopupCount mocks base method.
|
||||||
|
func (m *MockSingleAgent) GetAgentPopupCount(ctx context.Context, uid, agentID int64, agentPopupType playground.BotPopupType) (int64, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "GetAgentPopupCount", ctx, uid, agentID, agentPopupType)
|
||||||
|
ret0, _ := ret[0].(int64)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAgentPopupCount indicates an expected call of GetAgentPopupCount.
|
||||||
|
func (mr *MockSingleAgentMockRecorder) GetAgentPopupCount(ctx, uid, agentID, agentPopupType any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAgentPopupCount", reflect.TypeOf((*MockSingleAgent)(nil).GetAgentPopupCount), ctx, uid, agentID, agentPopupType)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPublishConnectorList mocks base method.
|
||||||
|
func (m *MockSingleAgent) GetPublishConnectorList(ctx context.Context, agentID int64) (*entity.PublishConnectorData, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "GetPublishConnectorList", ctx, agentID)
|
||||||
|
ret0, _ := ret[0].(*entity.PublishConnectorData)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPublishConnectorList indicates an expected call of GetPublishConnectorList.
|
||||||
|
func (mr *MockSingleAgentMockRecorder) GetPublishConnectorList(ctx, agentID any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPublishConnectorList", reflect.TypeOf((*MockSingleAgent)(nil).GetPublishConnectorList), ctx, agentID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPublishedInfo mocks base method.
|
||||||
|
func (m *MockSingleAgent) GetPublishedInfo(ctx context.Context, agentID int64) (*entity.PublishInfo, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "GetPublishedInfo", ctx, agentID)
|
||||||
|
ret0, _ := ret[0].(*entity.PublishInfo)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPublishedInfo indicates an expected call of GetPublishedInfo.
|
||||||
|
func (mr *MockSingleAgentMockRecorder) GetPublishedInfo(ctx, agentID any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPublishedInfo", reflect.TypeOf((*MockSingleAgent)(nil).GetPublishedInfo), ctx, agentID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPublishedTime mocks base method.
|
||||||
|
func (m *MockSingleAgent) GetPublishedTime(ctx context.Context, agentID int64) (int64, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "GetPublishedTime", ctx, agentID)
|
||||||
|
ret0, _ := ret[0].(int64)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPublishedTime indicates an expected call of GetPublishedTime.
|
||||||
|
func (mr *MockSingleAgentMockRecorder) GetPublishedTime(ctx, agentID any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPublishedTime", reflect.TypeOf((*MockSingleAgent)(nil).GetPublishedTime), ctx, agentID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetSingleAgent mocks base method.
|
||||||
|
func (m *MockSingleAgent) GetSingleAgent(ctx context.Context, agentID int64, version string) (*entity.SingleAgent, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "GetSingleAgent", ctx, agentID, version)
|
||||||
|
ret0, _ := ret[0].(*entity.SingleAgent)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetSingleAgent indicates an expected call of GetSingleAgent.
|
||||||
|
func (mr *MockSingleAgentMockRecorder) GetSingleAgent(ctx, agentID, version any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSingleAgent", reflect.TypeOf((*MockSingleAgent)(nil).GetSingleAgent), ctx, agentID, version)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetSingleAgentDraft mocks base method.
|
||||||
|
func (m *MockSingleAgent) GetSingleAgentDraft(ctx context.Context, agentID int64) (*entity.SingleAgent, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "GetSingleAgentDraft", ctx, agentID)
|
||||||
|
ret0, _ := ret[0].(*entity.SingleAgent)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetSingleAgentDraft indicates an expected call of GetSingleAgentDraft.
|
||||||
|
func (mr *MockSingleAgentMockRecorder) GetSingleAgentDraft(ctx, agentID any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSingleAgentDraft", reflect.TypeOf((*MockSingleAgent)(nil).GetSingleAgentDraft), ctx, agentID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IncrAgentPopupCount mocks base method.
|
||||||
|
func (m *MockSingleAgent) IncrAgentPopupCount(ctx context.Context, uid, agentID int64, agentPopupType playground.BotPopupType) error {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "IncrAgentPopupCount", ctx, uid, agentID, agentPopupType)
|
||||||
|
ret0, _ := ret[0].(error)
|
||||||
|
return ret0
|
||||||
|
}
|
||||||
|
|
||||||
|
// IncrAgentPopupCount indicates an expected call of IncrAgentPopupCount.
|
||||||
|
func (mr *MockSingleAgentMockRecorder) IncrAgentPopupCount(ctx, uid, agentID, agentPopupType any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IncrAgentPopupCount", reflect.TypeOf((*MockSingleAgent)(nil).IncrAgentPopupCount), ctx, uid, agentID, agentPopupType)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListAgentPublishHistory mocks base method.
|
||||||
|
func (m *MockSingleAgent) ListAgentPublishHistory(ctx context.Context, agentID int64, pageIndex, pageSize int32, connectorID *int64) ([]*entity.SingleAgentPublish, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "ListAgentPublishHistory", ctx, agentID, pageIndex, pageSize, connectorID)
|
||||||
|
ret0, _ := ret[0].([]*entity.SingleAgentPublish)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListAgentPublishHistory indicates an expected call of ListAgentPublishHistory.
|
||||||
|
func (mr *MockSingleAgentMockRecorder) ListAgentPublishHistory(ctx, agentID, pageIndex, pageSize, connectorID any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListAgentPublishHistory", reflect.TypeOf((*MockSingleAgent)(nil).ListAgentPublishHistory), ctx, agentID, pageIndex, pageSize, connectorID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MGetSingleAgentDraft mocks base method.
|
||||||
|
func (m *MockSingleAgent) MGetSingleAgentDraft(ctx context.Context, agentIDs []int64) ([]*entity.SingleAgent, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "MGetSingleAgentDraft", ctx, agentIDs)
|
||||||
|
ret0, _ := ret[0].([]*entity.SingleAgent)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// MGetSingleAgentDraft indicates an expected call of MGetSingleAgentDraft.
|
||||||
|
func (mr *MockSingleAgentMockRecorder) MGetSingleAgentDraft(ctx, agentIDs any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MGetSingleAgentDraft", reflect.TypeOf((*MockSingleAgent)(nil).MGetSingleAgentDraft), ctx, agentIDs)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ObtainAgentByIdentity mocks base method.
|
||||||
|
func (m *MockSingleAgent) ObtainAgentByIdentity(ctx context.Context, identity *entity.AgentIdentity) (*entity.SingleAgent, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "ObtainAgentByIdentity", ctx, identity)
|
||||||
|
ret0, _ := ret[0].(*entity.SingleAgent)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// ObtainAgentByIdentity indicates an expected call of ObtainAgentByIdentity.
|
||||||
|
func (mr *MockSingleAgentMockRecorder) ObtainAgentByIdentity(ctx, identity any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ObtainAgentByIdentity", reflect.TypeOf((*MockSingleAgent)(nil).ObtainAgentByIdentity), ctx, identity)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SavePublishRecord mocks base method.
|
||||||
|
func (m *MockSingleAgent) SavePublishRecord(ctx context.Context, p *entity.SingleAgentPublish, e *entity.SingleAgent) error {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "SavePublishRecord", ctx, p, e)
|
||||||
|
ret0, _ := ret[0].(error)
|
||||||
|
return ret0
|
||||||
|
}
|
||||||
|
|
||||||
|
// SavePublishRecord indicates an expected call of SavePublishRecord.
|
||||||
|
func (mr *MockSingleAgentMockRecorder) SavePublishRecord(ctx, p, e any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SavePublishRecord", reflect.TypeOf((*MockSingleAgent)(nil).SavePublishRecord), ctx, p, e)
|
||||||
|
}
|
||||||
|
|
||||||
|
// StreamExecute mocks base method.
|
||||||
|
func (m *MockSingleAgent) StreamExecute(ctx context.Context, req *entity.ExecuteRequest) (*schema.StreamReader[*entity.AgentEvent], error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "StreamExecute", ctx, req)
|
||||||
|
ret0, _ := ret[0].(*schema.StreamReader[*entity.AgentEvent])
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// StreamExecute indicates an expected call of StreamExecute.
|
||||||
|
func (mr *MockSingleAgentMockRecorder) StreamExecute(ctx, req any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StreamExecute", reflect.TypeOf((*MockSingleAgent)(nil).StreamExecute), ctx, req)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateAgentDraftDisplayInfo mocks base method.
|
||||||
|
func (m *MockSingleAgent) UpdateAgentDraftDisplayInfo(ctx context.Context, userID int64, e *entity.AgentDraftDisplayInfo) error {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "UpdateAgentDraftDisplayInfo", ctx, userID, e)
|
||||||
|
ret0, _ := ret[0].(error)
|
||||||
|
return ret0
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateAgentDraftDisplayInfo indicates an expected call of UpdateAgentDraftDisplayInfo.
|
||||||
|
func (mr *MockSingleAgentMockRecorder) UpdateAgentDraftDisplayInfo(ctx, userID, e any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateAgentDraftDisplayInfo", reflect.TypeOf((*MockSingleAgent)(nil).UpdateAgentDraftDisplayInfo), ctx, userID, e)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateSingleAgentDraft mocks base method.
|
||||||
|
func (m *MockSingleAgent) UpdateSingleAgentDraft(ctx context.Context, agentInfo *entity.SingleAgent) error {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "UpdateSingleAgentDraft", ctx, agentInfo)
|
||||||
|
ret0, _ := ret[0].(error)
|
||||||
|
return ret0
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateSingleAgentDraft indicates an expected call of UpdateSingleAgentDraft.
|
||||||
|
func (mr *MockSingleAgentMockRecorder) UpdateSingleAgentDraft(ctx, agentInfo any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateSingleAgentDraft", reflect.TypeOf((*MockSingleAgent)(nil).UpdateSingleAgentDraft), ctx, agentInfo)
|
||||||
|
}
|
||||||
@ -0,0 +1,148 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2025 coze-dev Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Code generated by MockGen. DO NOT EDIT.
|
||||||
|
// Source: domain/conversation/agentrun/service/agent_run.go
|
||||||
|
//
|
||||||
|
// Generated by this command:
|
||||||
|
//
|
||||||
|
// mockgen -destination internal/mock/domain/conversation/agentrun/agent_run_mock.go --package mock_agentrun -source domain/conversation/agentrun/service/agent_run.go
|
||||||
|
//
|
||||||
|
|
||||||
|
// Package mock_agentrun is a generated GoMock package.
|
||||||
|
package mock_agentrun
|
||||||
|
|
||||||
|
import (
|
||||||
|
context "context"
|
||||||
|
reflect "reflect"
|
||||||
|
|
||||||
|
schema "github.com/cloudwego/eino/schema"
|
||||||
|
entity "github.com/coze-dev/coze-studio/backend/domain/conversation/agentrun/entity"
|
||||||
|
gomock "go.uber.org/mock/gomock"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MockRun is a mock of Run interface.
|
||||||
|
type MockRun struct {
|
||||||
|
ctrl *gomock.Controller
|
||||||
|
recorder *MockRunMockRecorder
|
||||||
|
isgomock struct{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MockRunMockRecorder is the mock recorder for MockRun.
|
||||||
|
type MockRunMockRecorder struct {
|
||||||
|
mock *MockRun
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewMockRun creates a new mock instance.
|
||||||
|
func NewMockRun(ctrl *gomock.Controller) *MockRun {
|
||||||
|
mock := &MockRun{ctrl: ctrl}
|
||||||
|
mock.recorder = &MockRunMockRecorder{mock}
|
||||||
|
return mock
|
||||||
|
}
|
||||||
|
|
||||||
|
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||||
|
func (m *MockRun) EXPECT() *MockRunMockRecorder {
|
||||||
|
return m.recorder
|
||||||
|
}
|
||||||
|
|
||||||
|
// AgentRun mocks base method.
|
||||||
|
func (m *MockRun) AgentRun(ctx context.Context, req *entity.AgentRunMeta) (*schema.StreamReader[*entity.AgentRunResponse], error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "AgentRun", ctx, req)
|
||||||
|
ret0, _ := ret[0].(*schema.StreamReader[*entity.AgentRunResponse])
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// AgentRun indicates an expected call of AgentRun.
|
||||||
|
func (mr *MockRunMockRecorder) AgentRun(ctx, req any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AgentRun", reflect.TypeOf((*MockRun)(nil).AgentRun), ctx, req)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cancel mocks base method.
|
||||||
|
func (m *MockRun) Cancel(ctx context.Context, req *entity.CancelRunMeta) (*entity.RunRecordMeta, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "Cancel", ctx, req)
|
||||||
|
ret0, _ := ret[0].(*entity.RunRecordMeta)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cancel indicates an expected call of Cancel.
|
||||||
|
func (mr *MockRunMockRecorder) Cancel(ctx, req any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Cancel", reflect.TypeOf((*MockRun)(nil).Cancel), ctx, req)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create mocks base method.
|
||||||
|
func (m *MockRun) Create(ctx context.Context, runRecord *entity.AgentRunMeta) (*entity.RunRecordMeta, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "Create", ctx, runRecord)
|
||||||
|
ret0, _ := ret[0].(*entity.RunRecordMeta)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create indicates an expected call of Create.
|
||||||
|
func (mr *MockRunMockRecorder) Create(ctx, runRecord any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockRun)(nil).Create), ctx, runRecord)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete mocks base method.
|
||||||
|
func (m *MockRun) Delete(ctx context.Context, runID []int64) error {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "Delete", ctx, runID)
|
||||||
|
ret0, _ := ret[0].(error)
|
||||||
|
return ret0
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete indicates an expected call of Delete.
|
||||||
|
func (mr *MockRunMockRecorder) Delete(ctx, runID any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockRun)(nil).Delete), ctx, runID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetByID mocks base method.
|
||||||
|
func (m *MockRun) GetByID(ctx context.Context, runID int64) (*entity.RunRecordMeta, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "GetByID", ctx, runID)
|
||||||
|
ret0, _ := ret[0].(*entity.RunRecordMeta)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetByID indicates an expected call of GetByID.
|
||||||
|
func (mr *MockRunMockRecorder) GetByID(ctx, runID any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByID", reflect.TypeOf((*MockRun)(nil).GetByID), ctx, runID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// List mocks base method.
|
||||||
|
func (m *MockRun) List(ctx context.Context, ListMeta *entity.ListRunRecordMeta) ([]*entity.RunRecordMeta, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "List", ctx, ListMeta)
|
||||||
|
ret0, _ := ret[0].([]*entity.RunRecordMeta)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// List indicates an expected call of List.
|
||||||
|
func (mr *MockRunMockRecorder) List(ctx, ListMeta any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockRun)(nil).List), ctx, ListMeta)
|
||||||
|
}
|
||||||
@ -0,0 +1,163 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2025 coze-dev Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Code generated by MockGen. DO NOT EDIT.
|
||||||
|
// Source: domain/conversation/conversation/service/conversation.go
|
||||||
|
//
|
||||||
|
// Generated by this command:
|
||||||
|
//
|
||||||
|
// mockgen -destination internal/mock/domain/conversation/conversation/conversation_mock.go --package mock_conversation -source domain/conversation/conversation/service/conversation.go
|
||||||
|
//
|
||||||
|
|
||||||
|
// Package mock_conversation is a generated GoMock package.
|
||||||
|
package mock_conversation
|
||||||
|
|
||||||
|
import (
|
||||||
|
context "context"
|
||||||
|
reflect "reflect"
|
||||||
|
|
||||||
|
entity "github.com/coze-dev/coze-studio/backend/domain/conversation/conversation/entity"
|
||||||
|
gomock "go.uber.org/mock/gomock"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MockConversation is a mock of Conversation interface.
|
||||||
|
type MockConversation struct {
|
||||||
|
ctrl *gomock.Controller
|
||||||
|
recorder *MockConversationMockRecorder
|
||||||
|
isgomock struct{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MockConversationMockRecorder is the mock recorder for MockConversation.
|
||||||
|
type MockConversationMockRecorder struct {
|
||||||
|
mock *MockConversation
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewMockConversation creates a new mock instance.
|
||||||
|
func NewMockConversation(ctrl *gomock.Controller) *MockConversation {
|
||||||
|
mock := &MockConversation{ctrl: ctrl}
|
||||||
|
mock.recorder = &MockConversationMockRecorder{mock}
|
||||||
|
return mock
|
||||||
|
}
|
||||||
|
|
||||||
|
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||||
|
func (m *MockConversation) EXPECT() *MockConversationMockRecorder {
|
||||||
|
return m.recorder
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create mocks base method.
|
||||||
|
func (m *MockConversation) Create(ctx context.Context, req *entity.CreateMeta) (*entity.Conversation, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "Create", ctx, req)
|
||||||
|
ret0, _ := ret[0].(*entity.Conversation)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create indicates an expected call of Create.
|
||||||
|
func (mr *MockConversationMockRecorder) Create(ctx, req any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockConversation)(nil).Create), ctx, req)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete mocks base method.
|
||||||
|
func (m *MockConversation) Delete(ctx context.Context, id int64) error {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "Delete", ctx, id)
|
||||||
|
ret0, _ := ret[0].(error)
|
||||||
|
return ret0
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete indicates an expected call of Delete.
|
||||||
|
func (mr *MockConversationMockRecorder) Delete(ctx, id any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockConversation)(nil).Delete), ctx, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetByID mocks base method.
|
||||||
|
func (m *MockConversation) GetByID(ctx context.Context, id int64) (*entity.Conversation, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "GetByID", ctx, id)
|
||||||
|
ret0, _ := ret[0].(*entity.Conversation)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetByID indicates an expected call of GetByID.
|
||||||
|
func (mr *MockConversationMockRecorder) GetByID(ctx, id any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByID", reflect.TypeOf((*MockConversation)(nil).GetByID), ctx, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCurrentConversation mocks base method.
|
||||||
|
func (m *MockConversation) GetCurrentConversation(ctx context.Context, req *entity.GetCurrent) (*entity.Conversation, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "GetCurrentConversation", ctx, req)
|
||||||
|
ret0, _ := ret[0].(*entity.Conversation)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCurrentConversation indicates an expected call of GetCurrentConversation.
|
||||||
|
func (mr *MockConversationMockRecorder) GetCurrentConversation(ctx, req any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCurrentConversation", reflect.TypeOf((*MockConversation)(nil).GetCurrentConversation), ctx, req)
|
||||||
|
}
|
||||||
|
|
||||||
|
// List mocks base method.
|
||||||
|
func (m *MockConversation) List(ctx context.Context, req *entity.ListMeta) ([]*entity.Conversation, bool, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "List", ctx, req)
|
||||||
|
ret0, _ := ret[0].([]*entity.Conversation)
|
||||||
|
ret1, _ := ret[1].(bool)
|
||||||
|
ret2, _ := ret[2].(error)
|
||||||
|
return ret0, ret1, ret2
|
||||||
|
}
|
||||||
|
|
||||||
|
// List indicates an expected call of List.
|
||||||
|
func (mr *MockConversationMockRecorder) List(ctx, req any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockConversation)(nil).List), ctx, req)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewConversationCtx mocks base method.
|
||||||
|
func (m *MockConversation) NewConversationCtx(ctx context.Context, req *entity.NewConversationCtxRequest) (*entity.NewConversationCtxResponse, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "NewConversationCtx", ctx, req)
|
||||||
|
ret0, _ := ret[0].(*entity.NewConversationCtxResponse)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewConversationCtx indicates an expected call of NewConversationCtx.
|
||||||
|
func (mr *MockConversationMockRecorder) NewConversationCtx(ctx, req any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewConversationCtx", reflect.TypeOf((*MockConversation)(nil).NewConversationCtx), ctx, req)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update mocks base method.
|
||||||
|
func (m *MockConversation) Update(ctx context.Context, req *entity.UpdateMeta) (*entity.Conversation, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "Update", ctx, req)
|
||||||
|
ret0, _ := ret[0].(*entity.Conversation)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update indicates an expected call of Update.
|
||||||
|
func (mr *MockConversationMockRecorder) Update(ctx, req any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockConversation)(nil).Update), ctx, req)
|
||||||
|
}
|
||||||
132
backend/internal/mock/domain/shortcutcmd/shortcut_cmd_mock.go
Normal file
132
backend/internal/mock/domain/shortcutcmd/shortcut_cmd_mock.go
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2025 coze-dev Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Code generated by MockGen. DO NOT EDIT.
|
||||||
|
// Source: domain/shortcutcmd/service/shortcut_cmd.go
|
||||||
|
//
|
||||||
|
// Generated by this command:
|
||||||
|
//
|
||||||
|
// mockgen -destination internal/mock/domain/shortcutcmd/shortcut_cmd_mock.go --package mock_shortcutcmd -source domain/shortcutcmd/service/shortcut_cmd.go
|
||||||
|
//
|
||||||
|
|
||||||
|
// Package mock_shortcutcmd is a generated GoMock package.
|
||||||
|
package mock_shortcutcmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
context "context"
|
||||||
|
reflect "reflect"
|
||||||
|
|
||||||
|
entity "github.com/coze-dev/coze-studio/backend/domain/shortcutcmd/entity"
|
||||||
|
gomock "go.uber.org/mock/gomock"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MockShortcutCmd is a mock of ShortcutCmd interface.
|
||||||
|
type MockShortcutCmd struct {
|
||||||
|
ctrl *gomock.Controller
|
||||||
|
recorder *MockShortcutCmdMockRecorder
|
||||||
|
isgomock struct{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MockShortcutCmdMockRecorder is the mock recorder for MockShortcutCmd.
|
||||||
|
type MockShortcutCmdMockRecorder struct {
|
||||||
|
mock *MockShortcutCmd
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewMockShortcutCmd creates a new mock instance.
|
||||||
|
func NewMockShortcutCmd(ctrl *gomock.Controller) *MockShortcutCmd {
|
||||||
|
mock := &MockShortcutCmd{ctrl: ctrl}
|
||||||
|
mock.recorder = &MockShortcutCmdMockRecorder{mock}
|
||||||
|
return mock
|
||||||
|
}
|
||||||
|
|
||||||
|
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||||
|
func (m *MockShortcutCmd) EXPECT() *MockShortcutCmdMockRecorder {
|
||||||
|
return m.recorder
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateCMD mocks base method.
|
||||||
|
func (m *MockShortcutCmd) CreateCMD(ctx context.Context, shortcut *entity.ShortcutCmd) (*entity.ShortcutCmd, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "CreateCMD", ctx, shortcut)
|
||||||
|
ret0, _ := ret[0].(*entity.ShortcutCmd)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateCMD indicates an expected call of CreateCMD.
|
||||||
|
func (mr *MockShortcutCmdMockRecorder) CreateCMD(ctx, shortcut any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateCMD", reflect.TypeOf((*MockShortcutCmd)(nil).CreateCMD), ctx, shortcut)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetByCmdID mocks base method.
|
||||||
|
func (m *MockShortcutCmd) GetByCmdID(ctx context.Context, cmdID int64, isOnline int32) (*entity.ShortcutCmd, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "GetByCmdID", ctx, cmdID, isOnline)
|
||||||
|
ret0, _ := ret[0].(*entity.ShortcutCmd)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetByCmdID indicates an expected call of GetByCmdID.
|
||||||
|
func (mr *MockShortcutCmdMockRecorder) GetByCmdID(ctx, cmdID, isOnline any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByCmdID", reflect.TypeOf((*MockShortcutCmd)(nil).GetByCmdID), ctx, cmdID, isOnline)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListCMD mocks base method.
|
||||||
|
func (m *MockShortcutCmd) ListCMD(ctx context.Context, lm *entity.ListMeta) ([]*entity.ShortcutCmd, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "ListCMD", ctx, lm)
|
||||||
|
ret0, _ := ret[0].([]*entity.ShortcutCmd)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListCMD indicates an expected call of ListCMD.
|
||||||
|
func (mr *MockShortcutCmdMockRecorder) ListCMD(ctx, lm any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListCMD", reflect.TypeOf((*MockShortcutCmd)(nil).ListCMD), ctx, lm)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PublishCMDs mocks base method.
|
||||||
|
func (m *MockShortcutCmd) PublishCMDs(ctx context.Context, objID int64, cmdIDs []int64) error {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "PublishCMDs", ctx, objID, cmdIDs)
|
||||||
|
ret0, _ := ret[0].(error)
|
||||||
|
return ret0
|
||||||
|
}
|
||||||
|
|
||||||
|
// PublishCMDs indicates an expected call of PublishCMDs.
|
||||||
|
func (mr *MockShortcutCmdMockRecorder) PublishCMDs(ctx, objID, cmdIDs any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PublishCMDs", reflect.TypeOf((*MockShortcutCmd)(nil).PublishCMDs), ctx, objID, cmdIDs)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateCMD mocks base method.
|
||||||
|
func (m *MockShortcutCmd) UpdateCMD(ctx context.Context, shortcut *entity.ShortcutCmd) (*entity.ShortcutCmd, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "UpdateCMD", ctx, shortcut)
|
||||||
|
ret0, _ := ret[0].(*entity.ShortcutCmd)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateCMD indicates an expected call of UpdateCMD.
|
||||||
|
func (mr *MockShortcutCmdMockRecorder) UpdateCMD(ctx, shortcut any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateCMD", reflect.TypeOf((*MockShortcutCmd)(nil).UpdateCMD), ctx, shortcut)
|
||||||
|
}
|
||||||
118
backend/internal/mock/domain/upload/upload_service_mock.go
Normal file
118
backend/internal/mock/domain/upload/upload_service_mock.go
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2025 coze-dev Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Code generated by MockGen. DO NOT EDIT.
|
||||||
|
// Source: domain/upload/service/interface.go
|
||||||
|
//
|
||||||
|
// Generated by this command:
|
||||||
|
//
|
||||||
|
// mockgen -destination internal/mock/domain/upload/upload_service_mock.go --package mock_upload -source domain/upload/service/interface.go UploadService
|
||||||
|
//
|
||||||
|
|
||||||
|
// Package mock_upload is a generated GoMock package.
|
||||||
|
package mock_upload
|
||||||
|
|
||||||
|
import (
|
||||||
|
context "context"
|
||||||
|
reflect "reflect"
|
||||||
|
|
||||||
|
service "github.com/coze-dev/coze-studio/backend/domain/upload/service"
|
||||||
|
gomock "go.uber.org/mock/gomock"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MockUploadService is a mock of UploadService interface.
|
||||||
|
type MockUploadService struct {
|
||||||
|
ctrl *gomock.Controller
|
||||||
|
recorder *MockUploadServiceMockRecorder
|
||||||
|
isgomock struct{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MockUploadServiceMockRecorder is the mock recorder for MockUploadService.
|
||||||
|
type MockUploadServiceMockRecorder struct {
|
||||||
|
mock *MockUploadService
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewMockUploadService creates a new mock instance.
|
||||||
|
func NewMockUploadService(ctrl *gomock.Controller) *MockUploadService {
|
||||||
|
mock := &MockUploadService{ctrl: ctrl}
|
||||||
|
mock.recorder = &MockUploadServiceMockRecorder{mock}
|
||||||
|
return mock
|
||||||
|
}
|
||||||
|
|
||||||
|
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||||
|
func (m *MockUploadService) EXPECT() *MockUploadServiceMockRecorder {
|
||||||
|
return m.recorder
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetFile mocks base method.
|
||||||
|
func (m *MockUploadService) GetFile(ctx context.Context, req *service.GetFileRequest) (*service.GetFileResponse, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "GetFile", ctx, req)
|
||||||
|
ret0, _ := ret[0].(*service.GetFileResponse)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetFile indicates an expected call of GetFile.
|
||||||
|
func (mr *MockUploadServiceMockRecorder) GetFile(ctx, req any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetFile", reflect.TypeOf((*MockUploadService)(nil).GetFile), ctx, req)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetFiles mocks base method.
|
||||||
|
func (m *MockUploadService) GetFiles(ctx context.Context, req *service.GetFilesRequest) (*service.GetFilesResponse, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "GetFiles", ctx, req)
|
||||||
|
ret0, _ := ret[0].(*service.GetFilesResponse)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetFiles indicates an expected call of GetFiles.
|
||||||
|
func (mr *MockUploadServiceMockRecorder) GetFiles(ctx, req any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetFiles", reflect.TypeOf((*MockUploadService)(nil).GetFiles), ctx, req)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UploadFile mocks base method.
|
||||||
|
func (m *MockUploadService) UploadFile(ctx context.Context, req *service.UploadFileRequest) (*service.UploadFileResponse, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "UploadFile", ctx, req)
|
||||||
|
ret0, _ := ret[0].(*service.UploadFileResponse)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// UploadFile indicates an expected call of UploadFile.
|
||||||
|
func (mr *MockUploadServiceMockRecorder) UploadFile(ctx, req any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UploadFile", reflect.TypeOf((*MockUploadService)(nil).UploadFile), ctx, req)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UploadFiles mocks base method.
|
||||||
|
func (m *MockUploadService) UploadFiles(ctx context.Context, req *service.UploadFilesRequest) (*service.UploadFilesResponse, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "UploadFiles", ctx, req)
|
||||||
|
ret0, _ := ret[0].(*service.UploadFilesResponse)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// UploadFiles indicates an expected call of UploadFiles.
|
||||||
|
func (mr *MockUploadServiceMockRecorder) UploadFiles(ctx, req any) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UploadFiles", reflect.TypeOf((*MockUploadService)(nil).UploadFiles), ctx, req)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user