package services
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestAgentService_Execute(t *testing.T) {
// Arrange
ctx := context.Background()
svc := NewAgentService(mockRepo, mockEngine)
tests := []struct {
name string
agentID int64
task string
want string
wantErr bool
}{
{
name: "successful execution",
agentID: 1,
task: "Hello",
want: "Response",
wantErr: false,
},
{
name: "agent not found",
agentID: 999,
task: "Hello",
want: "",
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// Act
got, err := svc.Execute(ctx, tt.agentID, tt.task)
// Assert
if tt.wantErr {
require.Error(t, err)
return
}
require.NoError(t, err)
assert.Equal(t, tt.want, got)
})
}
}