You've already forked agentic-coding-workflow
完善 MCP 工具
This commit is contained in:
@@ -76,8 +76,19 @@ func newFakeProjectSvc(ps ...*project.Project) *fakeProjectSvc {
|
||||
}
|
||||
return f
|
||||
}
|
||||
func (f *fakeProjectSvc) Create(_ context.Context, _ project.Caller, _ project.CreateProjectInput) (*project.Project, error) {
|
||||
panic("not implemented")
|
||||
func (f *fakeProjectSvc) Create(_ context.Context, c project.Caller, in project.CreateProjectInput) (*project.Project, error) {
|
||||
v := in.Visibility
|
||||
if v == "" {
|
||||
v = project.VisibilityPrivate
|
||||
}
|
||||
p := &project.Project{
|
||||
ID: uuid.New(), Slug: in.Slug, Name: in.Name, Description: in.Description,
|
||||
Visibility: v, OwnerID: c.UserID, CreatedAt: time.Now(),
|
||||
}
|
||||
f.projects = append(f.projects, p)
|
||||
f.slugMap[p.Slug] = p
|
||||
f.idMap[p.ID] = p
|
||||
return p, nil
|
||||
}
|
||||
func (f *fakeProjectSvc) Get(_ context.Context, _ project.Caller, slug string) (*project.Project, error) {
|
||||
if p, ok := f.slugMap[slug]; ok {
|
||||
@@ -94,14 +105,38 @@ func (f *fakeProjectSvc) GetByID(_ context.Context, _ project.Caller, id uuid.UU
|
||||
func (f *fakeProjectSvc) List(_ context.Context, _ project.Caller, _ bool) ([]*project.Project, error) {
|
||||
return f.projects, nil
|
||||
}
|
||||
func (f *fakeProjectSvc) Update(_ context.Context, _ project.Caller, _ string, _ project.UpdateProjectInput) (*project.Project, error) {
|
||||
panic("not implemented")
|
||||
func (f *fakeProjectSvc) Update(ctx context.Context, c project.Caller, slug string, in project.UpdateProjectInput) (*project.Project, error) {
|
||||
p, err := f.Get(ctx, c, slug)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if in.Name != nil {
|
||||
p.Name = *in.Name
|
||||
}
|
||||
if in.Description != nil {
|
||||
p.Description = *in.Description
|
||||
}
|
||||
if in.Visibility != nil {
|
||||
p.Visibility = *in.Visibility
|
||||
}
|
||||
return p, nil
|
||||
}
|
||||
func (f *fakeProjectSvc) Archive(_ context.Context, _ project.Caller, _ string) error {
|
||||
panic("not implemented")
|
||||
func (f *fakeProjectSvc) Archive(ctx context.Context, c project.Caller, slug string) error {
|
||||
p, err := f.Get(ctx, c, slug)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
now := time.Now()
|
||||
p.ArchivedAt = &now
|
||||
return nil
|
||||
}
|
||||
func (f *fakeProjectSvc) Unarchive(_ context.Context, _ project.Caller, _ string) error {
|
||||
panic("not implemented")
|
||||
func (f *fakeProjectSvc) Unarchive(ctx context.Context, c project.Caller, slug string) error {
|
||||
p, err := f.Get(ctx, c, slug)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p.ArchivedAt = nil
|
||||
return nil
|
||||
}
|
||||
|
||||
// fakeRequirementSvc implements project.RequirementService.
|
||||
@@ -234,11 +269,19 @@ func (f *fakeIssueSvc) Reopen(_ context.Context, _ project.Caller, slug string,
|
||||
|
||||
// fakeWorkspaceSvc implements workspace.WorkspaceService.
|
||||
type fakeWorkspaceSvc struct {
|
||||
items []*workspace.Workspace
|
||||
items []*workspace.Workspace
|
||||
branches []string
|
||||
}
|
||||
|
||||
func (f *fakeWorkspaceSvc) Create(_ context.Context, _ workspace.Caller, _ string, _ workspace.CreateWorkspaceInput) (*workspace.Workspace, error) {
|
||||
panic("not implemented")
|
||||
func (f *fakeWorkspaceSvc) Create(_ context.Context, _ workspace.Caller, _ string, in workspace.CreateWorkspaceInput) (*workspace.Workspace, error) {
|
||||
w := &workspace.Workspace{
|
||||
ID: uuid.New(), ProjectID: testPID,
|
||||
Slug: in.Slug, Name: in.Name, Description: in.Description,
|
||||
GitRemoteURL: in.GitRemoteURL, DefaultBranch: in.DefaultBranch,
|
||||
SyncStatus: workspace.SyncStatusIdle, CreatedAt: time.Now(),
|
||||
}
|
||||
f.items = append(f.items, w)
|
||||
return w, nil
|
||||
}
|
||||
func (f *fakeWorkspaceSvc) Get(_ context.Context, _ workspace.Caller, id uuid.UUID) (*workspace.Workspace, error) {
|
||||
for _, w := range f.items {
|
||||
@@ -251,14 +294,37 @@ func (f *fakeWorkspaceSvc) Get(_ context.Context, _ workspace.Caller, id uuid.UU
|
||||
func (f *fakeWorkspaceSvc) List(_ context.Context, _ workspace.Caller, _ string) ([]*workspace.Workspace, error) {
|
||||
return f.items, nil
|
||||
}
|
||||
func (f *fakeWorkspaceSvc) Update(_ context.Context, _ workspace.Caller, _ uuid.UUID, _ workspace.UpdateWorkspaceInput) (*workspace.Workspace, error) {
|
||||
panic("not implemented")
|
||||
func (f *fakeWorkspaceSvc) Update(ctx context.Context, c workspace.Caller, id uuid.UUID, in workspace.UpdateWorkspaceInput) (*workspace.Workspace, error) {
|
||||
w, err := f.Get(ctx, c, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if in.Name != nil {
|
||||
w.Name = *in.Name
|
||||
}
|
||||
if in.Description != nil {
|
||||
w.Description = *in.Description
|
||||
}
|
||||
if in.DefaultBranch != nil {
|
||||
w.DefaultBranch = *in.DefaultBranch
|
||||
}
|
||||
return w, nil
|
||||
}
|
||||
func (f *fakeWorkspaceSvc) Delete(_ context.Context, _ workspace.Caller, _ uuid.UUID) error {
|
||||
panic("not implemented")
|
||||
func (f *fakeWorkspaceSvc) Delete(ctx context.Context, c workspace.Caller, id uuid.UUID) error {
|
||||
if _, err := f.Get(ctx, c, id); err != nil {
|
||||
return err
|
||||
}
|
||||
kept := f.items[:0]
|
||||
for _, w := range f.items {
|
||||
if w.ID != id {
|
||||
kept = append(kept, w)
|
||||
}
|
||||
}
|
||||
f.items = kept
|
||||
return nil
|
||||
}
|
||||
func (f *fakeWorkspaceSvc) Sync(_ context.Context, _ workspace.Caller, _ uuid.UUID) (*workspace.Workspace, error) {
|
||||
panic("not implemented")
|
||||
func (f *fakeWorkspaceSvc) Sync(ctx context.Context, c workspace.Caller, id uuid.UUID) (*workspace.Workspace, error) {
|
||||
return f.Get(ctx, c, id)
|
||||
}
|
||||
func (f *fakeWorkspaceSvc) UpsertCredential(_ context.Context, _ workspace.Caller, _ uuid.UUID, _ workspace.UpsertCredentialInput) (*workspace.Credential, error) {
|
||||
panic("not implemented")
|
||||
@@ -267,7 +333,7 @@ func (f *fakeWorkspaceSvc) GetCredentialMeta(_ context.Context, _ workspace.Call
|
||||
panic("not implemented")
|
||||
}
|
||||
func (f *fakeWorkspaceSvc) ListBranches(_ context.Context, _ workspace.Caller, _ uuid.UUID) ([]string, error) {
|
||||
panic("not implemented")
|
||||
return f.branches, nil
|
||||
}
|
||||
|
||||
// ===== test helpers =====
|
||||
|
||||
Reference in New Issue
Block a user